How do I load/save an equation in array

0 favourites
  • 3 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi,

    If you have an equation that uses local variables, is it possible to save/load that equation in an array in a useful way?

    Let's say you have local variables "A", "B" and "C", and an equation like "lerp(A,B,C)", and you write that equation to an array. Is it possible to configure a condition that loads that array slot equation to variable "D" in a way that Construct will calculate the result of the equation, using your preset local variables, instead of thinking the array slot data is a string?

  • It's not possible. You will need to parse this string, and if you want to support many different equations or expressions, this will be a very difficult task.

    You can try math.js:

    mathjs.org

    Replace variable names in the string with their values, then feed it to mathjs, and it will calculate the result.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, good to know.

    It would have been handy to be able to dynamically choose an equation from an array, but I can work around this limitation.

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