Is there a way to automatically add commas to large numbers?

When dealing with large numbers over 1,000, is there a way to String them so that they automatically display commas? Or do I have to it manually?

I’m not aware of any expressions. You could do it through events or JavaScript. If you use it in several places then you could create an expression and use it whereever needed.

What about spaces?
Rather than 1,000, how do we do 1 000?

JavaScript actually has an easy function. If you understand how to use it with Gdevelop.

The method toLocaleString() converts a number to a string with the current locale setting. You can add a locale like toLocaleString(‘en’) for commas and toLocaleString(‘en’) for the French format with spaces and commas instead of periods. Otherwise, I believe it’s automatic.

Add a JavaScript event and copy/paste this code. Make the javascript a subevent of a button. This creates random numbers and sets the values to the label of a button control named BlackDecoratedButton but the variable can be used anywhere.

The Javascript get the value in varNum and sets it to both varForrmattedNum and varFormattedFrenchNum

// Get Value from Scene Variable Names varNum
let Value = runtimeScene.getVariables().get("varNum").getAsNumber();

//convert to local style and set to string variable varFormated Number using commas as in English
let FormattedNum = Value.toLocaleString('en');

//convert to French style and set to string variable varFrenchFormated Number using spaces as in French
let FrenchFormat = Value.toLocaleString('fr-FR');

NOTE: this probably needs some checks and balances to make sure you’re providing a number and not text.

Also, the preferable method for JavaScript is through an extension. Passing it parameters and getting a return value. I could help with that part.