benkuper / Chataigne

Artist-friendly Modular Machine for Art and Technology
https://benjamin.kuperberg.fr/chataigne
GNU General Public License v3.0
1.22k stars 58 forks source link

Request: Custom script error "Unknown function toFixed" - maybe add "toFixed" function to Chataigne? #250

Closed ThomZenTury closed 1 month ago

ThomZenTury commented 2 months ago

Hi there! Firstly, thanks for the great application. I really enjoy testing it so far.

I was just trying to write a simple custom script with the purpose of limiting the amount decimal digits to a given number. I tried different approaches to use the common JS "toFixed()" function. The basic part would look like this:

...
   result[i] =  inputs[i]).toFixed(3);
   result[i] = Number(inputs[i]).toFixed(3);
   result[i] = parseFloat(inputs[i]).toFixed(3);
...

Unfortunately always with the same result.

Unknown function "toFixed"

Would it be a god idea to make "toFixed" accessible in Chataigne?

Have a nice day!

P.S.: For the moment I would be also grateful for another way to limit the amount of decimals in my output. Is there an implemented way in Chataigne?

benkuper commented 1 month ago

Chataigne 2 will implement QuickJS and will be fully ECMA202 compliant.