Trouble with variables

Ahoy all. So I've watched a few different video tutorials and have been playing around inside MZ in order to try and better grasp variables and how to use them (something I had a LOT of trouble with in my previous attempts to RPGM years ago, for some reason variables were a difficult thing for me to get my head around).

I think I've mostly got it now, but there is one thing happening that's puzzling me. While playing around with different ways to set and use variables, I set up this event, with the trigger of "Action Button" (and a random crystal for a graphic, so this happens when I talk to the crystal):
1652229039203.png

and then nearby, I have another event which was set to run as a parallel process, and has this in it:
1652229174330.png


No doubt you can see what I was trying to test - I talk to the crystal, it sets variable 16 to be equal to "the number of Mithril Swords in my inventory". Then it gives me a mithril sword, which should thus mean that variable 16 is now 1. Then the other event immediately begins making the SHOCKED! music effect repeatedly since it's dependent on variable 16 being 1.

BUT... what happens when I playtest is that it DOESN'T start making the sound when I have 1 sword. I talk to the crystal and it gives me a sword, but then nothing happens, even though there is indeed 1 Mithril Sword in my inventory. Only when I talk to the crystal again, increasing the number of Mithril Swords in my inventory to 2, does the Shocked sound begin to play repeatedly.

So what am I missing here? If all variables start at 0 when the game begins, then based on the above event commands, shouldn't the sound play after I have been given 1 sword?
control variable "item in inventory" gives the number that is in inventory AT THE MOMEMT THE COMMAND IS GIVEN.

in your event sequence, first you load the event with the number of mithril swords that is ZERO.
then you increase the number of mithril swords by one.

but you never update the variable to the new number of swords, so the other event never gets to that point, because the variable is still zero

Oh, and if you get multiple swotd the other event won't fire again because it only fires on =1, not on =2 or >=1
control variable "item in inventory" gives the number that is in inventory AT THE MOMEMT THE COMMAND IS GIVEN.

in your event sequence, first you load the event with the number of mithril swords that is ZERO.
then you increase the number of mithril swords by one.

but you never update the variable to the new number of swords, so the other event never gets to that point, because the variable is still zero

Oh, and if you get multiple swotd the other event won't fire again because it only fires on =1, not on =2 or >=1
Oh interesting! I swapped the order of commands in the crystal event, so that it gave me the sword THEN established that variable 16 = number of swords, which made it work (the sound played when I had 1 sword in my inventory, but did not play if I had 2 or 0 in my inventory).

So does this mean, effectively, that variables don't "update" along with the data they were told to be tied to? e.g. each time I wanted to rely on the number of Mithril Swords as a condition for an event to run, I'd need to make sure that there's a command to set variable 16 to equal the number of swords. I couldn't just set that once at the beginning of the game and then leave it alone.
So does this mean, effectively, that variables don't "update" along with the data they were told to be tied to?
No, that would defeat the entire point of them. If you want to always look at the current value of something, just look at that value.

The point of a variable is to store something to be referenced and manipulated separately from the original value. That could be because that value is transitory so you need to store it. It could be because you want to use it for math of some sort without affecting that original value. But a variable is a copy.
told to be tied to
there is no tying to at all.
the command is "load this value now", nothing more.

I usually reserve "temporary" variables that are used and ignored for calculation reasons, exactly because nothing automatically ties or updates any variable.
Got it. This makes a lot more sense now - while I'd managed to get a better grasp of how to use variables than I had in years prior, I still had the erroneous impression that they were somehow more of a "set" thing, than they actually are - something that was activated and then became whatever you told it to be, in a more permanent fashion.

Where I got that impression I couldn't tell you, and I'm not sure why variables in particular have been such a tough thing for me to really get a good handle on as RPGM tools go, but I think I have it at long last, lol. Thanks to both of you for your help!

Original thread: https://forums.rpgmakerweb.com/threads/trouble-with-variables.147482/