Set variable x

I've been looking all over for some form of how to do this, but I couldn't find any.
I simply want to know how to set variable x, where x is the value of another variable. For example, if the independent variable is set to 3, it will change the value of variable 3. If it is set to 4, the of variable 4. At the moment, I have conditional branches that check the value of the first variable and set them that way. (if variable 100=1, set variable 1 etc) But this is an extremely long and complicated method, and gets even more so if I want to increase the number of variable that can be changed this way later. If there is a plugin or script call that can do this that would be great to know.
Using Events:
1 Make a new event
2 on page 1 of event commands, go to control variables.
3. On control variables select variable 3.
4. make the operation set.
5. make operand variable 4.


Using Script Calls/JS code:
$gameVariables.setValue(3, $gameVariables.value(4));
What the code above says is set variable with id 3, to the current value of variable 4.

Now Variable 3 is set to what ever Variable was set to.

Note that variable 4 has to be set to a number before you set variable 3 equal to what ever it has.
Using Events:
1 Make a new event
2 on page 1 of event commands, go to control variables.
3. On control variables select variable 3.
4. make the operation set.
5. make operand variable 4.


Using Script Calls/JS code:
$gameVariables.setValue(3, $gameVariables.value(4));
What the code above says is set variable with id 3, to the current value of variable 4.

Now Variable 3 is set to what ever Variable was set to.

Note that variable 4 has to be set to a number before you set variable 3 equal to what ever it has.

I understand how to set a variable to another variable, but what I mean is how to set multiple variables based on the value of another variable. I do want to set variable x to the value of variable y, but I want variable x's ID to be the value of variable z.
@emperorlulu

Let me used the example I used then.

$gameVariables.setValue($gameVariable.value(5), $gameVariables.value(4));
Set the variable that is equal to the current value of variable 5 to the current value variable of 4.

So let's say variable 5 is set to 7, abd variable 4 is equal to 100.
Then variable 7 is set to 100.

And as always set variable 5 & 4 to the values you want.

As this code:
$gameVariables.setValue(x, y);
means set variable id x to the value of y. Where x & y means any javascript eval/code. Most people put numbets but you can put variable values, ids of classes or anything else you can think if.
@emperorlulu

Let me used the example I used then.

$gameVariables.setValue($gameVariable.value(5), $gameVariables.value(4));
Set the variable that is equal to the current value of variable 5 to the current value variable of 4.

So let's say variable 5 is set to 7, abd variable 4 is equal to 100.
Then variable 7 is set to 100.

And as always set variable 5 & 4 to the values you want.

As this code:
$gameVariables.setValue(x, y);
means set variable id x to the value of y. Where x & y means any javascript eval/code. Most people put numbets but you can put variable values, ids of classes or anything else you can think if.

I know that this will work for what I need, but it just says $gameVariable not defined when it executes. I copied it exactly, only changing the variable IDs, so I'm not sure what's wrong.
$gameVariables.setValue($gameVariables.value(5), $gameVariables.value(4));
Sorry, it was a typo.
$gameVariables.setValue($gameVariables.value(5), $gameVariables.value(4));
Sorry, it was a typo.
haha, looks like just a single letter was off. Just shoes why I couldn't figure this out myself if I didn't even notice that. regardless, looks like that was just what I needed, so thanks a lot!
$gameVariables.setValue($gameVariables.value(5), $gameVariables.value(4));
Sorry, it was a typo.
I actually have one more question. I need to set a variable equal to the value of variable x. Kinda the opposite of earlier. instead of setting different variables with one command it sets one variable equal to the value of multiple variables, if you know what I mean.
I actually have one more question. I need to set a variable equal to the value of variable x. Kinda the opposite of earlier. instead of setting different variables with one command it sets one variable equal to the value of multiple variables, if you know what I mean.

If you mean how to set the value of a variable to another variable, you can do that with the Control Variables event command.
@emperorlulu AFAIK a variable can only hold 1 value at a time, not multiple ones.

Now this:
$gameVariables.setValue(y, $gameVariables.value(x));

this means variable y is equal to the value of variable x.
@emperorlulu AFAIK a variable can only hold 1 value at a time, not multiple ones.

Actually, a variable CAN hold multiple values. It can hold as many values as you want by converting it into an array. However, assuming that the OP is still sort of new to MV, I would suggest not trying to do so until you're more familiar with the program.

Original thread: https://forums.rpgmakerweb.com/threads/set-variable-x.81801/