I have global variables : money = 123 and STATS = "money|something|...|"
Now I want to load money from STATS with this : tokenat(STATS,0,"|"), question is how to convert "money" into 123?
from the manual:
https://www.scirra.com/manual/126/system-expressions
int(x)
Convert the float or text x to an integer (whole number). If x is text, non-numeric characters are allowed after the number, but not before. For example int("33xx") returns 33, but int("xx33") returns 0.
Okay, but is it possible to convert string("money") into value of this variable(123)?
I guess using replace would be the expression to use:
replace(src, find, rep)
Find all occurrences of find in src and replace them with rep.
So that would be
system set Stats = replace(Stats, "money", str(money))
Develop games in your browser. Powerful, performant & highly capable.
Solved, LittleStain thanks for your help
Instead of STATS = "money|something|...|", I created function which set STATS to money&"|"&something
then tokenat(STATS,0,"|") will work