Adding and subtracting variables with scripts

voxet

Veteran
Veteran
Joined
May 25, 2022
Messages
41
Reaction score
20
First Language
english
Primarily Uses
RMMV
i put this in as a test (lost level being the name of my var with 2 as its id) and it is not working
and advice on where i can learn more about using variables in scripts becuase i wanna go on to do some more advanced operations

1654706694072.png
 

SeaPhoenix

Veteran
Veteran
Joined
May 14, 2015
Messages
370
Reaction score
481
First Language
English
Primarily Uses
RMMV
$gameVariables.value just gives you the actual value of that variable. To set it to a particular value, you need to use $gameVariables.setValue. So, for example, $gameVariables.setValue(2, 10) will set variable 2 to the value of 10.

To add to and subtract from the variable, you could use
JavaScript:
$gameVariables.setValue(2, $gameVariables.value(3) - 10)
which will set variable 2 = variable 3 - 10.

Note that these operations can all be done using a couple of event commands (without scripting), unless you have something different in mind.

You can see a list of MV's script calls here: https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-mz-script-call-list.46456/
 

Latest Profile Posts

I just realized that the 69th Common Event in my game is for the skill "Fall for Me," which inflicts Enthrall on all foes. :kaodes:
FallForMe.png
ScreenShot_10_1_2022_3_48_29.png
Wave's Elite guard comes to attack while you traverse Lab 5... They've got jetpacks too.
Making a weapon stronger according to the user level!
God, I wish I could afford a big band for my game. Not like... Foo Fighters or whatever. A big brass band. For ridiculous jazzy nonsense ala
Let it be known that I am very forgetful, and I often forget that I was engaged in conversation with people
here (and every other community I'm on). So if I ever stop replying to PMs or comments, please don't take it personally and just send me a reminder to reply XD

Forum statistics

Threads
125,708
Messages
1,172,941
Members
164,841
Latest member
tommy8bit
Top