Timer and Custom Fonts
mesaticus
Member Posts: 51
So I found this great example at gshelper on timers and custom fonts.
From this example I used the huge timer example at the bottom 00:00:00:00 (hours:minutes:seconds:milliseconds) only to use the seconds with a "countdown" attribute set to 99.
The key code on EACH of these actors in the example was as follows:
floor((( game.countdownTime %60)% self.divisor )/( self.divisor /10))
but I notice only the second number in the seconds works. When I run things I get "09, 08, 07, 05, 05, 04, 03, 02, 01, 00, 09, 08, 07...etc"
I'm not sure what I need to change on the other digit to display the first digit in my countdown timer. The odd things is if I divide by "100" at the end, the number does display but starts at 3, not 9.
Comments
What is the value of self.divisor? And how is game.countdownTime incrementing? Is it an integer decreasing by 1 every second...?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Without knowing more, my guess is you probably need to change it to this:
floor((( game.countdownTime %60)% (self.divisor*10) )/( self.divisor /10))
I based that on trying the following:
floor((( 85 %60)%10 )/( 10 /10)) = 2 floor((( 85 %60)%100 )/( 10 /10)) = 25
By the way, Spotlight is a great tool for trying such calculations. Just copy and paste either of those lines above and you can alter values to see the results.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Good grief ! That's great, I never knew that, very useful - have an 'awesome'.
Thanks for the help @tatiang (the Spotlight tip is awesome).
So based on what you said, I feel things should have worked. Divisor is an attribute with a value of 10 so your assumption with the numbers were right. I plugged in your formula and still nada.
I posted the file I'm working off of here: https://dl.dropboxusercontent.com/u/5820347/customTimer.zip
I appreciate the help.
Here's your expression:
floor((( game.countdownSeconds 60)% ( self.divisor *10))/( self.divisor /10))
Note that you are missing a mod symbol % before the 60.
Try this for the tens' digit, but make self.divisor 100:
floor((( game.countdownTime %60)% (self.divisor) )/( self.divisor/10))
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Awesome @tatiang. Thank you. That did the trick!
At first I noticed some funkiness since my countdownTime was set to 99 and that %60 was, I'm assuming, putting it on a 60sec scale. I lowered that attribute and saw things were functioning just fine with your corrections. Afterwards I removed that %60 from the tens digit and was able to show a countdown timer about 60, which is awesome!
Thanks again for your help.
You're welcome! Glad it's working for you.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User