Include commas in display text?
K1dTrunks
PRO Posts: 55
Is there any way to display an index/integer attribute and include the commas?
For instance, I want game.score to display as 5,678 but it only shows 5678.
Any simple way to do this without spawning comma actors? I need to display some game stats and it sucks when you're trying to read a really big number like 3876029 without commas!
For instance, I want game.score to display as 5,678 but it only shows 5678.
Any simple way to do this without spawning comma actors? I need to display some game stats and it sucks when you're trying to read a really big number like 3876029 without commas!
Comments
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
floor(( self.score %100000000)/(10000000))..floor(( self.score %10000000)/(1000000))..","..floor(( self.score %1000000)/(100000))..floor(( self.score %100000)/(10000))..floor(( self.score %10000)/(1000))..",".. floor(( self.score %1000)/(100)).. floor(( self.score %100)/(10)).. floor(( self.score %10)/(1))
It might look complicated (because its displaying digits out into the milllions), but its a pretty straight forward pattern. And once you get it working ... well... it just works!
The attribute "self.score" is not typed in. Instead you use the drop-down menu in the expression editor.
The function "floor()" is not typed in. Instead you use the other drop-down menu.
Here is an example.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I avoided using all those math rules by having a separate little actor that would DisplayText a comma only when the value was above 999. The spacing of the numbers allowed me to do that. I had to fiddle with the placement because the text would appear higher or lower in the preview than it did on the device...
Here's a free kid's math app (Counting Box) where you can see the effect: https://itunes.apple.com/app/id500496367
Good luck!