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 Posts

Latest Profile Posts

i want to make videogame, though i am burned out on games with RPG elements, but the only gamedev tool i know how to use is rpg maker. :/
Rakon wrote on xizorandy's profile.
Hello! I found a post of lightning strike pictures you posted. You said you made them, am I allowed to use them in my commercial project. Would be really cool!^^
evhht2zr.png

Have a nice day!
It's almost 3 month and this piece of drawing is still not finished yet.
aaaa.jpg

Really busy with other stuffs like commission and coping with personal problem.
Stella & Elyune, maybe used for promotional art if my game project finished one day.

Forum statistics

Threads
112,256
Messages
1,066,849
Members
145,866
Latest member
Hallistra
Top