Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Will on Mon 22/10/2018 14:37:25

Title: AGS: How Do I Make A Hidden Timer in AGS?
Post by: Will on Mon 22/10/2018 14:37:25
Hello Guys,

Could you tell me how do I make a Hidden Countdown Timer to A Game in AGS? I would like to know. Thank you! :)
Title: Re: AGS: How Do I Make A Hidden Timer in AGS?
Post by: Matti on Mon 22/10/2018 15:26:48
I'm not sure what you mean by hidden timer, but if you look up SetTimer in the manual I think you will find what you need.
Title: Re: AGS: How Do I Make A Hidden Timer in AGS?
Post by: Lewis on Tue 23/10/2018 08:04:03
Yeah, all timers are "hidden" unless you specifically script something to happen while the timer's running.

Assuming you just want to set a timer and have it count down to a game event, then

Code (ags) Select
SetTimer(1, 80);

will set Timer No. 1 to 80 game loops, i.e. 2 seconds. You want to set this at the point in the script where you want the timer to start counting down.

Then, in RepEx, you control what happens when the timer reaches 0. This is so that the game is checking every loop to see if there's any time left.

Code (ags) Select
if (IsTimerExpired(1)) //This continually checks whether or not Timer No. 1 has expired and returns the below if it has.
  {
    //Whatever you want to happen
  }
Title: Re: AGS: How Do I Make A Hidden Timer in AGS?
Post by: Will on Tue 23/10/2018 17:38:30
Thanks but...

How do I know if I set by Let's just say 7 Seconds... What should be it's int timeout integer of it?
Title: Re: AGS: How Do I Make A Hidden Timer in AGS?
Post by: Khris on Tue 23/10/2018 17:43:43
Use this:
  SetTimer(1, GetGameSpeed() * 7);

That way the timer will expire after 7 seconds regardless of the frames per second setting (which is 40 by default, so you pass 280 or 40 * 7).