GDevelop-extensions
GDevelop-extensions copied to clipboard
New extension: Format Number
Description
Adds two methods of formatting numbers (by separator and unit measure), both useful for clicker games.
How to use the extension
Adds two methods of formatting numbers (by separator and unit measure), both useful for clicker games.
- Use the expression
FormatBySeparatorto format a number by the specified separator. (Example: 1000000 will result in 1,000,000) - Use the expression
FormatByUnitto format a number by unit measure. (Example: 1000 will result in 1K, and 1000000 will result in 1M)
How to use the FormatByUnit expression:
- Create an array variable of any scope. (Object, scene or global.)
- Add one child for each unit measure (k, M, B, T, ...) -> (You can customize it.)
- At the expression, insert the variable in JSON string format:
Object variable - ObjectVarToJSON(Variable)
Scene variable - ToJSON(Variable)
Global variable - GlobalVarToJSON(Variable)
Important information:
- You can use the expression
FormatByUnitSceneif you want to just type out the scene array variable. - There is a hidden global array variable version aswell, but use it at your own risk, since it can break in future GDevelop releases. It is recommended to just convert the global variable to a JSON string instead, and use it at the
FormatByUnitexpression. (TheFormatByUnitSceneexpression is safe to use.)
Checklist
- [X] I've followed all of the best practices.
- [X] I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
- [X] I am aware that the extension may be updated by anyone, and do not need my explicit consent to do so.
What tier of review do you aim for your extension?
Community (Unreviewed)