How to make the usage of an item alter a variable?

It's time for another one of these questions. I looked this up last night, but everyone else who needed to make an item change a variable was doing this for a specific purpose that wasn't mine, and got solutions that were specific to their design.

So, inspired by Spiderweb Software's Queen's Wish, I wanted to implement a system where consumables are limited by the amount of containers you have, rather than the number of consumables you purchase, and the container is returned after consumption. Now, I *can* do this through a series of common events, where each container category (i.e. sacks for food, bottles for medicine, syringes for stimulants) has its own common event that it calls, but I want to consolidate these into one common event that I can simply update with new container types, because I don't know how many types of container, and thus different common events, I'll actually want to use, and I prefer to keep things tidy.
Have you tried Control Variables > Game Data > Last Used Item ID in your common event? It's new to MZ, looks very handy! 🙂
So you're saying it could be done by:
- The item performs the "Return Containers" common event in addition to its normal effects.
- CE first sets a dedicated variable to the "last item used" ID.
- CE next checks if the value of that variable is within the range of the different categories of item to return, and returns the proper item within the check.

That sounds splendid! Thank you!
--unfortunately, it hit me like a brick just after posting the first post that this mechanic only means anything in a game where enemies respawn/randomly appear, and that's fundamentally at odds with the way I've designed the exploration/combat. Still, if I decide to remake Dark Souls in RPG Maker, I'll be sure to remember that that's something I can do.

I actually have a different question now--should I ask it here or make a new thread?
When it's a completly different question then you should start a new Thread so it can have a more meaningful title, if it somehow still belongs to the topic of this Thread you should ask here.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-the-usage-of-an-item-alter-a-variable.126463/