Reborn
November 29, 2023, 5:15am
1
Hi, incase you did not follow my previous topic , I’m submitting this extension that you can use to format numbers with commas (1,000,000) or automatically convert it to 1k, 1M, 1B, etc. (Don’t worry you can customize everything in the expressions.)
Download it from github along with an example project:
GDevelopApp:main
← GDevelopApp:extension/RebornOfc/1111
opened 09:53PM - 28 Nov 23 UTC
### Description
Adds two methods of formatting numbers (by separator and unit m… easure), 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 `FormatBySeparator` to format a number by the specified separator. (Example: 1000000 will result in 1,000,000)
- Use the expression `FormatByUnit` to format a number by unit measure. (Example: 1000 will result in 1K, and 1000000 will result in 1M)
How to use the `FormatByUnit` expression:
1. Create an array variable of any scope. (Object, scene or global.)
2. Add one child for each unit measure (k, M, B, T, ...) -> (You can customize it.)
3. At the expression, insert the variable in JSON string format:
Object variable - `ObjectVarToJSON(Variable)`
Scene variable - `ToJSON(Variable)`
Global variable - `GlobalVarToJSON(Variable)`
Important information:
1. You can use the expression `FormatByUnitScene` if you want to just type out the scene array variable.
2. 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 `FormatByUnit` expression. (The `FormatByUnitScene` expression is **safe** to use.)
### Checklist
- [X] I've followed all of [the best practices](http://wiki.compilgames.net/doku.php/gdevelop5/extensions/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)
### Example file
[FormatNumberExample.zip](https://github.com/GDevelopApp/GDevelop-extensions/files/13493571/FormatNumberExample.zip)
### Extension file
[FormatNumber.json.zip](https://github.com/GDevelopApp/GDevelop-extensions/files/13493572/FormatNumber.json.zip)
5 Likes
This is exactly what I need.
Maji
November 30, 2023, 12:34am
3
I need this. This can also be used to format 5 as “005”, but format 100 as “100”, perfect for retro scoreboards!