[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?
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?
You can do this in a script command, just replace the 1 and 2 with the IDs of the variables you want to swap:
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.
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.
Pages:
1














