GDevelop-extensions icon indicating copy to clipboard operation
GDevelop-extensions copied to clipboard

New extension: Format Number

Open github-actions[bot] opened this issue 2 years ago • 0 comments

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 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.
  • [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

Extension file

FormatNumber.json.zip

github-actions[bot] avatar Nov 28 '23 21:11 github-actions[bot]