So I'm using Mr. Trivel's Limited Inventory plugin, and I was wondering if there was a way to make it so when the player gets a new item while their inventory is full, instead of the new items disappearing, give the player an option to discard an old item and keep the new one. Also if there's a way to event a system like this or another plugin that would do the same thing that would work as well, I don't need to use this plugin specifically but none of the other inventory management plugins I've tried have had the features I'm looking for.
MV Mr. Trivel Limited Inventory - discard old item when inventory is full?
Javascript/Plugin SupportHi!
So, what I have seen into the code, I believe you can use a conditional branch with this script:
If this condition is true, means that the inventory space is full.
So you can use the default Event Item command to open the select item window.
After that, you store the selected item id into a variable and use that to exclude from the party's inventory the item you want.
If you are using the height system, you will probably have to put a loop there, to keep checking if you have free space for the new item. Otherwise, you will need to select another item to throw away.
So, what I have seen into the code, I believe you can use a conditional branch with this script:
$gameParty.getInventorySpaceUsed() === $gameParty.getInventorySpaceTotal()If this condition is true, means that the inventory space is full.
So you can use the default Event Item command to open the select item window.
After that, you store the selected item id into a variable and use that to exclude from the party's inventory the item you want.
If you are using the height system, you will probably have to put a loop there, to keep checking if you have free space for the new item. Otherwise, you will need to select another item to throw away.
Thanks for the help! So the conditional branch works, although once I have the player select an item and save it as a variable I'm not sure how to remove an item based on that variable. Also I see how you could set this up in the overworld with only giving the player an item once they have room in their inventory, but would this work for items received from battles as well?
You can use a script call to remove the item:
JavaScript:
const id = $gameVariables.value(varId)
const item = $dataItems[id]
const amount = 1
$gameParty.loseItem(item , amount)
But yeah, the event approach is only for the overworld.
To do that in battle, you probably will need another plugin or a patch on this one.
Alright, I got it working. Thanks again! Also I realized how I can get it to work after a battle, I'm using on map encounters so I can just run the event after victory and give items there instead of actually doing it it the battle.
Original thread: https://forums.rpgmakerweb.com/threads/mr-trivel-limited-inventory-discard-old-item-when-inventory-is-full.140200/