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
Quick question: is there a function that return true when a given string is a number?
int("string") > 0 will work other than for zero. Otherwise you could use a regular expression.
For additional precision you could use
"string" = "0"
int("string") != 0.
Develop games in your browser. Powerful, performant & highly capable.
There is a function that returns true when a given string is NOT a number. It's not wrapped in any System expression so you'll have to use the Browser.ExecJS expression.
Browser.ExecJS("!isNaN(""" & yourVar & """);")[/code:1zas59qt]
int(x) got one problem. If x < 1 (ie. 0.5), it will return 0, which is also the value to indicate that x is not a number. To remedy this, use float(x) instead.