Pause Timer?

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
kylekrack
Liquid Metal Slime
Posts: 1242
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Pause Timer?

Post by kylekrack »

Is there a simple way to pause a timer? If I use stop timer, is there any way to start it again, where it left off, or do I have to check the timer, then stop it, and then then set the timer again using the timer given by checking the timer? That seems overly complicated and I don't know if I want to try doing it before asking to make sure there isn't a simpler way of doing it.

EDIT: I'm asking because I'm adding a powerup in Crusty's Heyday which stops the clock, giving you more time (the game actually ends now, yay!).
Last edited by kylekrack on Sun Apr 05, 2015 7:55 am, edited 1 time in total.
My pronouns are they/them
Ps. I love my wife
User avatar
Gizmog
Metal King Slime
Posts: 2622
Joined: Tue Feb 19, 2008 5:41 am

Post by Gizmog »

I think you're on the right track with the "Start the timer with the old timer thing" like uhh

Code: Select all

stoptimer

SetTimer (1,ReadTimer (1),Whatever,Whatever,Whatever,etc)
wouldn't be too weird?
User avatar
kylekrack
Liquid Metal Slime
Posts: 1242
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

Yeah I went ahead and tried it out anyway. It works fine. I did something like that, don't really remember what. I used a variable I think. I surprise myself when things work.
My pronouns are they/them
Ps. I love my wife
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

"stop timer" actually pauses a timer, by setting its speed to zero. All you have to do to resume it is use "set timer" to set its speed back to the correct value. All arguments to settimer except for the timer ID are optional, and if you leave them out or write timer:default, then the value remains unchanged.

Code: Select all

stop timer (5)
...
set timer (5, timer:default, 18)  # 18 ticks per timer tick
Also, if you only have one timer, then you can use the "suspend timers" command, which pauses all of them.
User avatar
kylekrack
Liquid Metal Slime
Posts: 1242
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

Ah, ok, that makes more sense. The method I used is a bit more convoluted, but really not enough to go back and change it. I just passed the count argument for what the timer returned as it stopped, and that seems to work fine. Good to know that though, timers are very important to the process of this game. In this case, suspending them would not be the best, given I just hit 12 total yesterday. There's a lot of timers goin' on left and right in this game.
My pronouns are they/them
Ps. I love my wife
Post Reply