Set a variable value equal to another via scripting...

I was wondering if you could, for example, set the value of variable #2 = to the value of variable #5, but with scripting; the reason is that I have to set the value of 20+ variables but the first variable is like #102 and the next is #912 and is really tedious to do it from the conditional branch in the editor...

Thanks beforehand!
I think you're mixing up the wrong things here, because the conditional branch has nothing to do with setting a variable, it is for comparing variables.

Control variable is the command for setting variables, and that has a batch function exactly because it is not a comparison - but I admit that that batch function requires consecutive variables.

There IS a script function for access to variables - like there is for every event command, you should search and bookmark the pinned topic about the script equivalent of all event commands, that will help you a lot.

But before that you should really think about what you want to do, because using the wrong commands is even worse in scripting than in eventing, because the scripts have a lot of the event commands security checks removed.
I was wondering if you could, for example, set the value of variable #2 = to the value of variable #5, but with scripting; the reason is that I have to set the value of 20+ variables but the first variable is like #102 and the next is #912 and is really tedious to do it from the conditional branch in the editor...

Thanks beforehand!

$gameVariables.setValue(var1, $gameVariables.value(var2))
For example if you want to set the value of variable 5 to be equal to variable 2, then would be:
$gameVariables.setValue(5, $gameVariables.value(2))
Andar's advice is good - if you're doing something new, try to fully explain your situation to make sure you're given the best advice.

If you do need to do this, the syntax is:
Code:
$gameVariables.setValue(X, $gameVariables.value(Y));
where X and Y are the appropriate IDs (no leading zeros).
Thanks a lot for your responses! It worked perfectly.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/set-a-variable-value-equal-to-another-via-scripting.145364/