Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: metalmario991 on Sat 21/02/2015 23:39:31

Title: Cancelling Timers
Post by: metalmario991 on Sat 21/02/2015 23:39:31
In my game you need to do a certain event before 20 real-time minutes pass but I haven't figured out how to stop the timer when you accomplish this event. How would I get rid of the timer.
Title: Re: Cancelling Timers
Post by: tzachs on Sun 22/02/2015 02:59:21
From the manual (http://www.adventuregamestudio.co.uk/wiki/Game_/_Global_functions#SetTimer):
"Pass TIMEOUT as 0 to disable a currently running timer."
Title: Re: Cancelling Timers
Post by: Cassiebsg on Sun 22/02/2015 06:58:58
Isn't it true that timers "cancel" it self after they run out?

Think you want to setup your timer to run 20 minutes. And if I remember correctly (please correct me if I'm wrong, an not that good at math) the game runs at 40 cycles a second, which means 20min*60sec*40cycles=48000.

So, that would mean you need to set you timer to 48000. And then check for when it's run out. If you don't start that timer again in your code, then that should do it.
Title: Re: Cancelling Timers
Post by: Andail on Sun 22/02/2015 09:07:10
Yeah, Cassie, but op asked about cancelling the timer, so it wouldn't run out. Tzachs explained how to just that.
Title: Re: Cancelling Timers
Post by: metalmario991 on Sun 22/02/2015 13:25:03
Tzachs, how would that look like in code?
Title: Re: Cancelling Timers
Post by: tzachs on Sun 22/02/2015 14:58:01
Code (ags) Select

SetTimer(my_timer_id, 0);
Title: Re: Cancelling Timers
Post by: NickyNyce on Sun 22/02/2015 15:18:32
I had an issue with a timer starting inside a room, but not finishing before I left the room. When I came back in the room, things went haywire. I had to cancel it when leaving the room, just in case the player left before it ran out.

Not that this is relevant here, but just for reference.
Title: Negating Timers
Post by: metalmario991 on Tue 24/02/2015 15:49:54
I am still having trouble on cancelling timers. Here is what I am asking: How do you make sure a timer DOESN'T run out. You need to a get to a certain area in a certain time limit afterwards the timer should go away. How do I do this?
Title: Re: Cancelling Timers
Post by: Snarky on Tue 24/02/2015 16:17:34
Mario, don't start a new topic when you're just following up on an earlier question. tzachs already gave you the answer, so if you couldn't get it to work, show what went wrong.
Title: Re: Cancelling Timers
Post by: metalmario991 on Sun 01/03/2015 20:07:01
Yeah, sorry about that. I just was stressed a little. But it turns out a just had a real stupid moment and actually put in my timer id instead of the actual ID. I didn't realize my mistake until after I put that up. Again, sorry.