[RMMV] SCRIPT CALL FOR EXCHANGING VARIABLE VALUES?

Posts

Pages: 1
What is the script call to get 2 separate variables to switch values with one another? Why you want do this:
Ex: You want var 0001 (whose value is 20),
to exchange its value with var 0002 (whose value is 100).
With a control variable command, setting one to the other overwrites the initial one. Both would equal 20 or 100. To work around this you would need var 0003 to be set to the initial one first (whose value is scratch paper and a waste of time), and finally reset it. 3 commands! What a nuisance.
Also, I noticed a script option at the bottom of the control variable command window, is there anything special about using this rather than a script call?
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
You can do this in a script command, just replace the 1 and 2 with the IDs of the variables you want to swap:

temp = $gameVariables.value(1)
$gameVariables.setValue(1, $gameVariables.value(2))
$gameVariables.setValue(2, temp)

Also, the "script" option in Control Variable just allows you to set a variable's value using Javascript. It isn't really any different from using a script call, it just means you don't have to explicitly code the setting of the variable itself, just the value it'll contain.
Thank you! I tried writing a plugin like you suggested. I got sublime text, the split source files for RMMV. Me and my kids have been learning javascript all this week. It's just trial and error from here on out, just try it and have it crash 100 times until it does what you want right!
Pages: 1