Stop Scores from Turning into Scientific Notation
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 ?
If there is no way to stop the switch, is there a way to make it work? @tshirtbooth ?
Best Answer
-
Cluv Posts: 229
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
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