3 Digit Custom Score Math Issue
0belisk
PRO Posts: 189
So instead of using the Display Text for my in-game figures such as score im using the technique featured in the OSTime template, but heres the issue, on a 3 digit score system, i cant figure out how to correctly change the self.image of the 2nd image.
000 (integer values)
..^
for the third digit (hundred) im using constrain self.image to (floor(( game.Score )/100))..".png"
for the first digit (1-9) im using constrain self.image to (( game.Score )%10)..".png"
And i have the second digit working correctly up to 099, but once we get into the hundreds, i have the math confused.
How do i get the second digit (tenth) to display correctly when dealing with a 3 digit number system, so for example if the player is on 357 score, what equation would i require for the 5 to display a 5 as it should?
Basically, using the number 357, input an equation to divide it down to 5 so it changes to 5.png, and of course be generic to any number from 100-999 so it will correctly divide itself down to its appropriate number.png
Thanks in advance!
EDIT:
The closest i have gotten so far is by doing constrain self.image to (floor(( game.Score )%100)/10))..".png"
Which for example turned 357 into 5.7, which is close but it needs to be 5, as 5.7.png is invalid.
000 (integer values)
..^
for the third digit (hundred) im using constrain self.image to (floor(( game.Score )/100))..".png"
for the first digit (1-9) im using constrain self.image to (( game.Score )%10)..".png"
And i have the second digit working correctly up to 099, but once we get into the hundreds, i have the math confused.
How do i get the second digit (tenth) to display correctly when dealing with a 3 digit number system, so for example if the player is on 357 score, what equation would i require for the 5 to display a 5 as it should?
Basically, using the number 357, input an equation to divide it down to 5 so it changes to 5.png, and of course be generic to any number from 100-999 so it will correctly divide itself down to its appropriate number.png
Thanks in advance!
EDIT:
The closest i have gotten so far is by doing constrain self.image to (floor(( game.Score )%100)/10))..".png"
Which for example turned 357 into 5.7, which is close but it needs to be 5, as 5.7.png is invalid.
Comments
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
The floor of any number is a whole number, by definition (http://en.m.wikipedia.org/wiki/Floor_and_ceiling_functions). Why are you getting a decimal?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
the floor(357%100) turns it into 57, then the /10 brings it down to 5.7
So i tried reversing the ordering, to floor((357)/10)%100)..".png" and then you get 57.
for now i have just done what i explained in my previous post:
"The only solution i can think of is to make a self.attribute on the 2nd digit actor (integer) value, and constrain the self.image to that instead of the equation, then constrain the self.attribute to the equation which will force it to a interger value, canceling out the .7 on the end of the digit."
Which is indeed working, but it wasnt my preferred method of fixing it, but i guess ill be happy to keep this, unless you're able to shed some light :P
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User