Adding and subtracting variables with scripts

voxet

Regular
Regular
Joined
May 25, 2022
Messages
56
Reaction score
21
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

Regular
Regular
Joined
May 14, 2015
Messages
440
Reaction score
616
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 Threads

Latest Profile Posts

AAAGH... I hate navigating the new RPG Maker website!
Forgive my rudimentary video editing skills, thought I'd start sharing progress on my status posts as well. Here's the second character of my roster, Mǽlhafoc, the Ælven ranger.

And if you missed the first one many moons ago, here's Vilhelm, the tarnished knight.
Knocked through three more rough draft sprites. (A frog beast thing, a skeleton, and vampire bat) down to seven sprites and a thing more appropriately done as tiles.

Forum statistics

Threads
135,013
Messages
1,252,908
Members
177,938
Latest member
l3rgith
Top