Mark91

Veteran
Veteran
Joined
May 19, 2017
Messages
143
Reaction score
15
First Language
Italian
Primarily Uses
RMMV
Hi,
I have a variable that contain a number (in string form), how can I convert it in a simple number so that I can do operations on it?

Ie. I have varX = "5" and varY = "5".
If I do varX + varY it turns out 55.....
So... I think I need to convert those variables into numbers...?
 

Mark91

Veteran
Veteran
Joined
May 19, 2017
Messages
143
Reaction score
15
First Language
Italian
Primarily Uses
RMMV
Thanks!
If needed I solved my problem with this call script (thanks to Dev_With_Coffee link):

var num = $gameVariables.value(x);
$gameVariables.setValue(x, (parseInt(num)))
 

frogs_r_cool

Villager
Member
Joined
May 11, 2021
Messages
16
Reaction score
8
First Language
English
Primarily Uses
RMMZ
Food for thought:

parseInt() is safer, but some other fun ways that would work for your example are:

Number(varX )

or simply

+varX

You can add your two variables with +varX + +varY (but don't do this, lol)
 

Latest Threads

Latest Profile Posts

Bluh... glad this present heatwave is coming to a close...
Look what I found, it was my first ABS.

This project was never completed because I had lost the computer where it was stored.
Character Creator for RPGM 2000, VX, XP, & LPC Style Sprites | RPG Maker News #72

Is there any way to get more than 8 enemies in a troop in RMMV or is that limit pretty much hardcoded into the engine?
Stream will be live shortly with some game development! Feel free to drop by!

Forum statistics

Threads
112,276
Messages
1,067,021
Members
145,897
Latest member
cornmaniac
Top