How can i make a variable hold more than 1 item possession count

Hello! i am very sorry if this post is not in the place where it should be, its my first time asking for help in this site (ᵕ ´ ∇ ˋ ˶)

I have a system in my game of throwing various objects during a battle (made this using a skill that cost items), for this you can use multiple objects (cups, pots, pans). Since there are many objects, it is cumbersome to have them appear in the objects menu within the battle (because there are many of them, they would hinder the ability to see other more important objects) but it is still necessary for the player to be able to see how many objects they have available to throw. For this, I thought of a variable that considers how many objects you have and gives you a value corresponding to it, to be able to add it to the battlehud gui.
I tried to achieve this through a tutorial I found, but it's not really working for me, i had never scripted, I'm sure there's something I did wrong.
1740592780532.png
1740592882434.png

To test the variable, i used this event. But it doesn't work, having all the objects in the inventory, my idea is that in this case, the value is equal to 6
1740593058779.png
1740593123973.png

1740593178638.png


This is where i got the script tutorial from --> https://steamcommunity.com/sharedfiles/filedetails/?id=1889421166
This is where i got the game variable from --> https://forums.rpgmakerweb.com/index.php?threads/script-call-to-get-item-quantity.133619/
I hope this is understandable and it haves a solution! thank you very much, I'm sorry for the RPG Maker interface in Spanish.
you completely misunderstood the tutorial on steam.
holding two numbers in a variable does not add the numbers together, and that is also not how object variables are used either.

why don't you add the numbers together with control variables : item count?
you completely misunderstood the tutorial on steam.
holding two numbers in a variable does not add the numbers together, and that is also not how object variables are used either.

why don't you add the numbers together with control variables : item count?
Thank you for your reply! I tried to use control variables but it also went wrong; i replicated what i did before.
I thought maybe using this method (control variables) would give problems when the items are used and no longer in the inventory, since the variable relies only on adding and not substracting. Thats why i wanted to go for the script way.

1740596150692.png
1740596194154.png
1740596227144.png
I thought maybe using this method (control variables) would give problems when the items are used and no longer in the inventory, since the variable relies only on adding
as long as you reset the variable to 0 before trying to count your items every time you do, it should be fine.

i had never scripted, I'm sure there's something I did wrong.
also your script had errors in it that would result in the game skipping over the script command entirely. If youre using scripts, you can press f12 and open up the console so that if you end up making an error the game will inform you of it. i.e., missing the closing brackets for $dataItems[5] and 6
but it also went wrong
the first control variable should be using set, not add
add is only correct for the second command.

(that is basically the same as adding a command to set to zero, it's just easier this way)
Thank you both so much! i solved the problem
This thread is closed due to being indicated as solved. Report the next one so it is easy to find! If you need this one reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-make-a-variable-hold-more-than-1-item-possession-count.175852/