Include commas in display text?

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!

Comments

  • JarrenHJarrenH Member Posts: 206
    Try doing: (self.integer1)..","..(self.integer2) Note the two periods and quotation marks.
  • K1dTrunksK1dTrunks PRO Posts: 55
    @JarrenH - I imagine that would work for displaying two attributes with a comma in between, but I'm trying to display ONE (index) attribute with the appropriate commas within it. So if the attribute was 13853 I want it to display as 13,853.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    i think you'd have to use some math tricks to get each individual number and display them separately. search for custom font score and you should get an idea on what it will take. might not be worth the effort :)
  • K1dTrunksK1dTrunks PRO Posts: 55
    yeah, it's probably not worth it. Thanks anyway
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    To get it to show up in the display text behavior you would do something like this:

    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!
  • K1dTrunksK1dTrunks PRO Posts: 55
    Wow. Thanks @RThurman. :D
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    You build the display text behavior by using the expression editor.

    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.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Most math functions actually can be typed into the expression editor, but it's always wise to err on the side of caution and use the drop-down menus for most things.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • TomCoffeeTomCoffee Member, PRO Posts: 175
    On an old calculator a comma appears but the numbers don't shift or move... I used the same idea in one of my apps.

    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!
Sign In or Register to comment.