reset timer
jessica.michael
Member, PRO Posts: 27
Hello, yes I am asking another question, I have a timer counting down from ten to zero but I'm not sure how I can make it reset to 10 and count down again straight away without resetting the scene.
Comments
If you can show the rules you are using to create the timer someone can probably help easier.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
and I also have a game attribute for timer that is an integer and is set at 10
Mis-read actual problem. @tatiang has solution.
GSLearn.com | Templates | Free Demos | Udemy Course
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Am I missing something? There is no point in reseting it to 10 if the actor is being destroyed after 10 seconds anyway?
GSLearn.com | Templates | Free Demos | Udemy Course
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@Two.E Hmm, good point. But my understanding was that @jessica.michael wanted a timer that counted down from 10 and then immediately reset back to 10 in order to continue counting down.
So maybe remove the destroy actor behavior altogether...
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
And for anyone wondering, as I did, why mod(game.Timer-1,11) cycles through the values 10, 9, 8, ... 2, 1, 0, 10, 9, 8, ... instead of going negative when game.Timer is zero...
Here's a definition of the mod function (aka %) from the Lua Reference Manual:
a % b == a - math.floor(a/b) * b
So when game.Timer is zero, we get this:
-1 % 11 == -1 -floor(-1/11) * 11
== -1 -(-1 * 11)
== -1 +11
== 10
[My description of mod() as "the remainder from a division problem" wasn't entirely accurate because -1 divided by 11 = 0 with a remainder of -1 whereas the correct answer is 10 according to the equation above.]
But @Socks probably knew all that
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User