Stop Scores from Turning into Scientific Notation

ellfireellfire Member Posts: 187
edited May 2012 in Working with GS (Mac)
Is there anyway to stop an integer attribute from switching to scientific notation once it passes 100mil? I am using TSB's method of swapping in custom fonts for scores and, when the scores become high enough to switch into the sci notation, it no longer works because it can't find the correct corresponding digits for the proper number image. (Ex. 10's digit now is "e" etc.)

If there is no way to stop the switch, is there a way to make it work? @tshirtbooth ?

Best Answer

  • CluvCluv Posts: 229
    Accepted Answer
    If it is just to display and not to save, you can have a rule, plus a counter and a second variable to display the extra digits you are missing. Have the rule keep track of when you hit the top of the int variable. When it get there, reset the int, up the counter, and display the counter as a second variable that adds the upper digits that are missing. For example:


    Imagine the upper limit to X = 99
    Create Counter = 0

    When X = 99 set Counter = Counter + 1
    Reset X = 0
    Display Counter (1) beside your X (now at 0)

    Will display 10, but only for the first 9 digits. Then it will display as if 110, 121, etc.

    It isn't very elegant example, and it clearly has some issues, but the idea is there. In actuality, the counter is keeping track of every set of "99" you reach in the game. With a larger score, it may be more convenient for you to keep track of your millions and beyond in this way. Just have a counter that counts to whatever number you want (1 million) and when the score exceeds it, iterate the counter, reset your score with the left over 1, 10s or what-have-you (if you have gone over) and start again.

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Simple solution: have scores that don't exceed that number.

    Harder solution: my guess is that you'll need to convert the number before you attempt to display it or work with it further. So you might have to have something like game.scoreDividedBy10 that you use to display the custom font digits (based on floor(game.scoreDividedBy10/10)) and then add on an extra ones digit to display the missing number.

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

  • ellfireellfire Member Posts: 187
    Thanks @cluv and @tatiang. I'll give cluv's example a shot. In all honesty, there is probably a .01% chance anyone could ever score that high in my game. I never noticed it until I entered 123456789 as a score to double check the display. ;) And if someone is scoring that hi, I don't think they'll mind having 99 points or less lopped off the total.
  • CluvCluv Member Posts: 229
    @ellfire, sounds good. I hope it works out for you.
Sign In or Register to comment.