Hundreds of features to explore
Games made in Construct
Your questions answered
Trusted by schools and universities worldwide
Free education resources to use in the classroom
Students do not need accounts with us
What we believe
We are in this together
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.
I have a small problem. If I have a variable called "score" and the value is f.e "1235"
How do I collect what value the second number is? In this case 2
I know about the "mid" expression in text but can't get it to work on a number variable.
Develop games in your browser. Powerful, performant & highly capable.
Sounds like something an array would be better at. Sorry I don't know the answer.
I use arrays in my game but this should be pretty simple. You can do it in a text by using mid(text,2,1) to collect the second letter so I hoped there was a simple way to do it in a number variable as well
you should try : mid(str(score),2,1)
MadSpy Can always count on you
This seems to work so progress. This is the scenario. I have a sprite that I want to set the frame to the same number as the second number in a variable. How do I do that. I can get a string but it needs to be set back to a number to be used in the set animation frame action
set animation frame= int(mid(str("score"),2,1)
you can add a check that your score has 2 digits. (if len(str(Score))>=2)
MadSpy Thank you but it won't let me use that expression when I want to set the frame. It tells me it has to be a number :/
There's a typo in MadSpy's answer. It's missing a closing parenthesis :
set animation frame= int(mid(str(score),2,1))
Got it working. It was zero based So this did the trick int(mid(str(totaldeaths),1,1))
Thank you MadSpy !
Magistross Thank you. Just realized that
It's a long week and I 'm a little tired but the key is that you understand the trick ^^ Anonnymitet
Thx Magistross