How do I create abbreviations for large numbers in text objects?

I’ve been working on a project in GDevelop, and I’ve run into a bit of a problem when it comes to dealing with large numbers. Specifically, I’d like to abbreviate numbers like 1,000,000 to something simpler like “1M” or 1,000 to “1K", with a single decimal point, eg: 4.8K, 15.1M, 6.2T, 3.4Q, 2Qn, etc. to make things easier to read in the UI.

I’ve tried a few approaches to get this working, but I haven’t had much success so far. Some of the methods I’ve experimented with involve dividing numbers and appending text like “K” or “M” based on their size, but they either give me stuff like 1000M coming after 999.9 K, or 1.0001K or don’t give me the clean results I’m looking for.

Does anyone have a good solution for this? Maybe a specific way to use events or expressions to dynamically format these numbers? Or perhaps someone has already tackled this in their own project and can share how they approached it?

I’d really appreciate any guidance or examples you might have. These huge numbers are tough to handle, and I’m hoping to make the game look cleaner and more user-friendly.

Thanks in advance for your help!

Thanks, this looks promising! I can’t download it though, and it isn’t in the community extensions page, can you help with this? Sorry for being a little Github-dumb

Edit: I forgot to unzip the file :skull:
At least it works now! Solved

1 Like