Is there an easy way to convert a string to an expression? For example if Sprite.var1 = 5 then "sqrt(Sprite.var1+4)" would return 3.
Check this post:
construct.net/en/forum/construct-3/how-do-i-8/expressions-inside-array-153657
Develop games in your browser. Powerful, performant & highly capable.
Here's a mess of previous topics. There are probably more.
construct.net/en/forum/construct-3/how-do-i-8/math-result-text-line-145507
construct.net/en/forum/construct-3/how-do-i-8/create-programming-language-138650
construct.net/en/forum/construct-2/your-construct-creations-23/r0j0s-experiments-69314
Specific to what you're going for here's this:
More functions and expressions can be added in the "namelookup" function.
dropbox.com/s/beavbwwu1usywyg/parser_example.capx
It won't allow invalid syntax but the error messages need work.
Anyways, the simplest would be to do a few string replaces and running the expression with the browser's execjs expression. However this isn't forgiving if there are syntax errors and can be a problem if some arbitrary js is run.