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

So yesterday Dad took me to Volcano Bay, and it was almost ruined by a thunderstorm... then it passed by and the lightning warning got lifted, leading to an awesome time sliding and swimming. Hopefully we get to go to the arcade tonight. The one we're planning on has a restaurant built in with AWESOME food. Not to mention how big the arcade itself is!
image_2021-06-13_150033.png

Maybe I'll actually try making a retro pack. Already have the shark fin made so why not xD
Hey everyone, for everybody following along with my RPG Maker MZ streams: There will unfortunately not be a stream tonight. There is a big exciting event that will go live next week that has been taking all my time, so look forward to that!
Took a small break by playing VR. Latest update of these glasses unfortunately caused a little of trouble but it can be fixed with a manual operation.

Until You Fall is freaking awesome.
I am SO HYPED to share this trailer with everyone when its done. I almost want to tear up i had no idea how far i came along with Fallen Feather in these last 3 years.

Forum statistics

Threads
112,193
Messages
1,066,502
Members
145,802
Latest member
Corim
Top