Export range thousands separator

Godot Version

4.2.1

Question

I was wondering if there was a way to have Godot put thousands separators (like the commas in 10,000,000) into an exported range. Since the engine already has support for stuff like ‘suffix:m’ and ‘exp’, I wouldn’t be surprised if there was a way to define it.

For the inspector view you mean? That would be something to configure in the editor view, not on the property IMO

I know a way to shorten numbers using technical fields, although I don’t know how to do it in the way you are describing.

Technical Fields
Adding a letter at the end of a number is a shorthand way to express large numbers, commonly used in technical fields and online communication.

  • : Represents . So, 10k means 10,000.
  • : Represents . So, 500M means 500,000,000.
  • : Represents . So, 2.5B means 2,500,000,000.

These abbreviations are helpful because they save space and make it easier to read really big numbers. For instance, saying “10k followers” is quicker than saying “10,000 followers.”

Put this function at the top of your main scene script (or any script attached to a root node)
Or, you could put this in an Singletons (Global) Script to have access to it everywhere in your project.

func format_number(n: int) -> String:
    if n >= 1_000_000_000_000:
        # ran for every number <n> greater or equal to a trillion
        var i:float = snapped(float(n)/1_000_000_000_000, .01)
        return str(i).replace(",", ".") + "T"
    elif n >= 1_000_000_000:
        # ran for every number <n> smaller than 1 trillion BUT
        # still greater or equal to 1 Billion
        var i:float = snapped(float(n)/1_000_000_000, .01)
        return str(i).replace(",", ".") + "B"
    elif n >= 1_000_000:
        # ran for every number <n> smaller than 1 trillion BUT
        # still greater or equal to 1 million
        var i:float = snapped(float(n)/1_000_000, .01)
        return str(i).replace(",", ".") + "M"
    elif n >= 1_000:
        # ran for every number <n> smaller than 1 million BUT
        # still greater or equal to 1 thousand
        var i:float = snapped(float(n)/1_000, .01)
        return str(i).replace(",", ".") + "k"
    else:
        # ran otherwise
        return str(n)

# Note: the _ dividers between numbers are optional.
# just makes it easier to read.

The highest here is the Trillion. However, you can manually put more here. After the Trillion comes the Quadrillion. This function formats numbers up to 100T, BUT even if it goes past, for example 1 Quadrillion, it will return 1000T.

Here are some optional elifs you can put in the function (Must be between else and if statements)

    if n >= 1_000_000_000_000_000:
        # ran for every number <n> greater or equal to a Quadrillion
        var i:float = snapped(float(n)/1_000_000_000_000_000, .01)
        return str(i).replace(",", ".") + "q"

Do this with as many as you like.
if you need extra help, I’m here
If you are looking to use the aa, ab, ac system, I recommend visiting
this site and implementing it into your game: