How do I show a number with thousand separator?

0 favourites
  • 7 posts
From the Asset Store
A small template showing how to build a firebase ranking
  • This is a basic thing to add in normal programming, but I can't for the life of me find out how to do it in Construct 2...

    Fx. the number 1,000,000,000 looks quite unreadable when displayed as 1000000000...

    I'm making a game for which this will eventually be an issue (the user must be able to quickly read and compare very large numbers; billions to trillions to quadrillions etc.).

    Edit:

    My current workaround which I'll have to use if I can't display the thousands separator, would be IF-statements;

    fx. this (it was faster to just type like this than explain how to drag/drop in Construct 2)...:

    if (variable > 999999) { variable = (variable/1000000) & "million" }

    Btw. I also thought about counthing the string length for each number, then breaking it apart in to a certain number of variables, then reassembling into one number with my , separator in between... but I certainly hope that there's a more nice solution ^_^

  • Go to github. Search for sprintf for JavaScript. Call it with the browser object passing in your string and display the result.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Here are some topics with examples:

  • Thanks a lot, R0J0hound, may I ask how you found these threads...? I tried searching here and directly on Google, and came up empty handed... Also tried the manual of course, but no dice... ^_^

    I'd hoped for a thing similar to how "round" works, just with a parameter setting - but this is also a very viable workaround/solution you've linked to here! So thanks a bunch!

  • OOOOH and I just saw the other links - when I read the manual, I did wonder if regex could do the trick - and voila! And now I also learned about functions in Construct!

    I'm getting exponentially happier and happier for Construct as I learn it - DAMN it's PERFECT for me! It's like sculpting with very easy to use tools aka "make dinosaur button", and then being able to dive in with more precise tools, to make exactly what you want and need!

    Uuuuh time to play with regular expressions now! Thanks again!

  • Glad they helped. I found the topics using the forum search with "comma number".

  • Ah! I searched for "thousand separator" and "million separator" ^_^

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)