Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: MrAbu on Sun 26/11/2017 05:44:36

Title: How to pause a timer?
Post by: MrAbu on Sun 26/11/2017 05:44:36
I understand how to create and start a timer, and I know how to stop a timer, but is there a way to pause the timer and resume it from the paused point later?
Title: Re: How to pause a timer?
Post by: Slasher on Sun 26/11/2017 12:20:50
Look at this for starters...

http://www.adventuregamestudio.co.uk/forums/index.php?topic=44580.msg595303#msg595303
Title: Re: How to pause a timer?
Post by: Khris on Sun 26/11/2017 19:52:52
AGS doesn't support pausing timers, but you can always use your own variable instead.

// top of script
bool timerActive;
int timerValue;


  // start timer
  timerActive = true;
  timerValue = GetGameSpeed() * 30; // 30 seconds


  // in repeatedly_execute / room_RepExec
  if (timerActive) {
    if (timerValue == 0) {
      // timer expired
      timerActive = false; // turn off
      // STUFF HAPPENS
    }
    else timerValue--;  // count down
  }


You can now pause the timer at any point by calling timerActive = false;
Title: Re: How to pause a timer?
Post by: Monsieur OUXX on Mon 27/11/2017 17:09:38
...Or use this module for "better" timers

Timer v3.01 http://www.adventuregamestudio.co.uk/forums/index.php?topic=28979.0