Not possible to evaluate a string?

0 favourites
  • 2 posts
From the Asset Store
A collection of a mix of percussion and orchestral string loops, including 20 musical sketches.
  • I'm trying to use the Evaluate Expression condition to parse expressions stored in a variable, but the more I try, it's overwhelmingly seeming like this isn't possible. I've created the following simple block of code to demonstrate, but no matter whether the Expression variable is true or not, it always shows as true. Have I misunderstood the condition?

    Part of the reason I want to achieve this is to facilitate a rudimentary conditions function in the Flowchart tool. The idea is that certain nodes can have tags that will just be expressions ("Coins => 25", etc.) that can be read by the Evaluate Expression to determine the outcome. I'm aware that javascript has an eval() function that as far as I'm aware, allows for this exact thing, but Construct doesn't seem to recognise it.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yeah that condition just evaluates normal math expressions not an expression in a string.

    I think any non empty string besides “0” will be true.

    To evaluate an expression in a string you have some options:

    One way is to write a text parser to extract the operators and numbers and evaluate the expression. That would give you the most control over how it’s done.

    A second way is to use the browser objects execjs expression. It’s basically the eval function js has. It can’t reference variables though.

    Third option would be to find a plugin that evaluates text expressions. I’m sure someone made one before.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)