Rpg maker MV event, item, any amount.

I want to make an event where it checks the inventory of how many items i have of one type, in this case empty vials, to then trade them for filled water vials, and making it so that it gives back the same amount of water vials, but making this work for however many items you have... anyone knows how to make this work?
Thanks. 🙂
edit:
PS: currently i have it so it fills one vial each time, but another option to fill multiple or all in inventory would be nice.
Control Variables > Game Data > Item (empty vials) in Inventory

will give the number of empty vials.

Then just use that variable in a Change Items command to reduce your empty vials to 0, and in another Change Items command to increase your water-filled vials by the same amount.

The issue you might have here is if the player already has 80 filled vials and 30 empty ones, you'll take away the 30 but only give them back 19 due to the 99 items limit, unless you have a plugin to change that.

If you don't have a plugin, and it's possible that this might happen, then you need to have another variable that calculates how many more you can get, and if it's less than the number of empty vials you have, use that number instead (by saying 99 minus the number of filled vials in inventory).
Thanks, ill try to make it now 🙂 ill let u know how it goes.
will this work?
upload_2019-3-3_22-20-12.png
i think i made it work...
how do i make it so that it doesnt go over 99? wouldn't want the player to waste empty vials. EDIT: what plugin ignores the limit?
I ended up with having 2 options, either filling all vials or just 1 vial, so now there are 2 options 🙂
ill test out real quick to see what happens if i get more than 99.
so i figured out that even if i have 99 empty vials and fill them all, it won't go over 100, when i have some already. also, it says 2 when i have 99 in my inventory, even though it checks for how many i have? not sure why...
upload_2019-3-3_22-48-33.png
so here's a pic of what ive done so far.
You posted SEVEN times in a row there. Note, double posting (making multiple posts in a row) is against the forum rules. If you need to add/change something, just edit your last post instead.

To make it not go over 99, just do this ...

Code:
Control Variables 65 = Game Data > Item (empty vials) in Inventory
Control Variables 66 = 99
Control Variables 66 -= Game Data > Item (filled vials) in Inventory
Conditional Branch: Variable 66 < Variable 65
  Control Variables 65 = Variable 66
End

then do your change items stuff. So you're inserting all of those extra lines after you set variable 65 and before the change items commands.

In the case where you fill one at a time, just do a check first (control variables then conditional branch) to see how many filled vials are in inventory. If there are already 99, show a message that the player can't get any more. Otherwise (the Else branch), do the swap.
Thanks 🙂
EDIT: sorry about all the posts.
i think maybe i fixed it..
EDIT: i changed the maximum size of stacks to 1000, but still unsure if it'll destroy vials if u have 999 and try to fill 100, im guessing 99 would be destroyed at that point maybe...
guessing i just need another conditional branch, but not sure how to make it yet.
upload_2019-3-3_23-24-34.png
yes, it would be.

What you've done is not right. If the party has 99 filled vials, it won't let them have anymore. But if they have 98 filled files and 30 empty ones, it'll take the 30 empty ones and only give 1 filled one back.

I gave you the exact commands to run.
i tried them, but somehow nothing happened when i tried it... the empty vials didn't go away and no water vials appeared in my inventory either, so i tried making that instead.
edit: but is there any way we could make it work with what ive already got now?
no, because your logic is wrong. I'm sure you don't want to add tests for what to do if the player has 98 bottles of water, and 97 bottles of water, and 96 bottles of water (ie - 100 tests for 100 different amounts).

Put back the commands I gave you, test it, and if it doesn't work show a screenshot of what you've got. Make sure you use a new variable that isn't already used for something else. I just used the one after, but you might already have it allocated for another purpose.
Okay i'll give it another shot 🙂 edit: it didn't work, what did i do wrong?
upload_2019-3-4_0-23-52.png

Original thread: https://forums.rpgmakerweb.com/threads/rpg-maker-mv-event-item-any-amount.106362/