Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
Hi there i have a variable that is a number and i was wondering if i could set multiple text objects to different values in the variable.
For example is the variable is 156 would it be possible to set one text object to the 1 (hundreds value) another to the 5 (tens value) and the last one to the 6... all of the same variable.
you can make it a string (str(var)) and use the mid function to get a specific character
calculate the value with math: h=int(var/100), t=int((var-h*100)/10), s=var-h*100-t*10 (in this order)
Develop games in your browser. Powerful, performant & highly capable.
A general mechanism with the mid() expression.
tokenat("text", index, separator)
int(tokenat("text", 0, ",")&tokenat("text", 1, ",")&tokenat("text", 2, ","))
One more method! Math based, use modulo (%).
a=floor(x%10) = 6
b=floor((x%100)/10) = 5
c=floor((x%1000)/100) = 1
But still first method mercury mentioned is probably most straightforward.