The best way to set variable = item in inventory

I'm trying to create a common event that run on parallel that sets variable equal to amount of items in inventory. However; I got some problems;

The event contains wait command for a few frame (to reduce lag) then setting variables[5] = item no.7 in database. After that set conditional branch to check if v[5]>= 3 if yes, turn off a switch.

My problem is when I use an item to show a text box (call common event) and try to print v[5], it's always showing 0 eventhough I have 3 of item no. 7 in my inventory.

What is the best way to correct this?
a screen shot of your event would be best.

I'm not seeing an error in logic. Is  the event on and running continuously so it's updating the amount?
a screen shot of your event would be best.

I'm not seeing an error in logic. Is the event on and running continuously so it's updating the amount?
I wish I could give you a screenshot but I'm not at home now. It keeps bugging me so I post my topic here. Actual situation is player will get a quest to kill a monster for a drop. I use conditional drop script to make the monster drop the item when a swtich is turned on. So I set up variable to check if I get 3 of the item then will turn off the switch so the monster no longer drops the item.

I also use evented quest log rather than a completed script. I create a quest log item using it for showing text boxes (for quest's details). Also I want to show the amount of the item current have using \v[5]/3 but it always show 0/3 no matter how many the item I current have.
all that info helps nothing. your description of how it should work is correct, which means the error has to be in how you placed the logic into the events.


And to check that, we need to see the exact sequence of the commands and settings of the events and the items to identify the bug.


So please provide the asked for screenshots.
Like Andar said, we can be a lot more helpful if you provide screenshots.

One thing I'd try, to narrow the issue down further, is placing all of the processing in one action-button event to see what happens (so you can control when it's being run, and how many times).  Set the variable, do the conditional branch for the switch, and then directly call the Common Event (or even try directly calling the text box).  Copy the event commands wherever possible to make sure you preserve your correct/incorrect eventing for the test event.  Use a different map if possible.

If that works, you know you did something wrong with the interaction between the other events (or, less likely, the item that calls a Common Event).  If it's still showing 0, you know you did something wrong in your actual eventing (such as choosing the wrong Item to set the variable # equal to, or using the wrong Event Commands).

Also, make sure the constantly-running Common Event is set to Parallel Process and that the requisite Switch is ON during your testing.
How stupid I am that there is a wrong variable setting command in the common event when the quest log is used. After fixing that, it worked fine.

Thanks for all your answers guys!
If you don't want to display the number all the time you may consider just setting the variable right before you actually need it. That would save you the parallel loop and get rid of update delays. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/the-best-way-to-set-variable-item-in-inventory.37304/