Changing the Nth variable or switch

Heey everyone,

Hope this isn't a regular occurring question, cause it feels like more people would need this. What I would like is to change the value of a variable, but I want the number in the list of variables to be determined by another value. So in an example that would be:

I want to change the 12th variable (variable #0012) in the list to "5". So I store the number "12" inside another variable, say variable #0001. How would I call and change the (number that's stored in variable #0001)th number variable?

Is this possible in vanilla RPG Maker MV, or would I need a plug-in for this?? Thanks in advance for the help!

Douglas
You can do this with a Script call (third page of the Event Commands, bottom right).
In the script field, enter something like this:
Code:
$gameVariables.setValue($gameVariables.value(VARIABLE_THAT_STORES_THE_VARIABLE_ID), VALUE);
So for your example, the code should be this:
Code:
$gameVariables.setValue($gameVariables.value(1), 5);
This changes the variable #(number that's stored in variable #1) to 5.
You can do this with a Script call (third page of the Event Commands, bottom right).
In the script field, enter something like this:
Code:
$gameVariables.setValue($gameVariables.value(VARIABLE_THAT_STORES_THE_VARIABLE_ID), VALUE);
So for your example, the code should be this:
Code:
$gameVariables.setValue($gameVariables.value(1), 5);
This changes the variable #(number that's stored in variable #1) to 5.

Nice! That is exactly what I'm looking for! Muchos gracias!~

Original thread: https://forums.rpgmakerweb.com/threads/changing-the-nth-variable-or-switch.95055/