Add a calculator to the editor

I made the topic title as direct to the point as I could.

In my opinion, GDevelop lacks a way of checking the result of
some basic expressions in the editor itself. A way specifically like this: a separated simplistic calculator tab where we can write expressions, and evaluate their values.

It would work like this: There would be a new tab called Calculator. (Just like any tab, there would be an option to open it at the lateral panel.) After opening it, we would be able to write almost any expression there. (Only numeric and string expressions are allowed, we would not be able to reference objects and variables.)

Giving an example, if we type this:

StrLength(“TestString”)

Then, the result (10) would show up in a box.

Following that, mod(StrLength(“TestString”),3) would result as 1

If you try to type an unallowed expression, like this: Object.Variable(…) / 2 it would display an advice, saying that variables and object expressions cannot be referenced inside the calculator, since their value could be literally anything.

I am suggesting this because I always find myself opening a online javascript editor in a separated tab (because there I can create custom functions to make the syntax similar to the way we type expressions in GDevelop) so I can get a quick real-time evaluation of whatever I am trying to calculate, without being limited to a loop of:

Step 1: Spends minutes writting an expression.
Step 2: Hits preview to check the logged message to the console.
Step 3: Sees that the result is not what I wanted.
Step 4: Goes back to rewrite the expression.

Just to then realize that fixing it will be very annoying, because, since I can’t evaluate the value of the expression in real-time, I have to guess what I have to do to make it work at the next try.

2 Likes