Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: monkey0506 on Mon 28/03/2005 16:58:54

Title: rep_ex_always and a Timer
Post by: monkey0506 on Mon 28/03/2005 16:58:54
For two of my GUIs (VOLUME and TEXTSPEED) I want to allow them to turn on during speech with the keypresses that affect their values:

VOLUME
'-' = minus
'=' = plus

TEXTSPEED
'[' = minus
']' = plus

In order to do this, I have to call them from rep_ex_always.  I understand that much.  The problem lies with turning them off.  I did use a simple integer and decrement it from rep_ex, but that doesn't run during speech (even if the game is paused during speech (to my knowledge (and experience))) so, the question is how to implement a timer.  I had the int "timer" set to 100 so that it could decrement once a game loop until it reached 0 at which point it turned both GUIs off.  I tried using the built-in timers (SetTimer and IsTimerExpired) but I couldn't get that to work properly either.

So...how can I make it to where my GUIs turn off after 100 game loops (as rep_ex_always runs faster than the game speed)?  It's not necessarily essential to change them during speech, but it was possible in the interface I'm emulating...

Thanks for any help!
Title: Re: rep_ex_always and a Timer
Post by: Kweepa on Tue 29/03/2005 02:14:21
rep_ex_always is called during speech.
Seems simple enough...


int turnOnVolumeGui = 0;
int turnOffVolumeGuiCounter = 0;

function rep_ex_always()
{
  if (turnOnVolumeGui == 1)
  {
    turnOnVolumeGui = 0;
    GUIOn(VOLUME);
    turnOffVolumeGuiCounter = 3*GetGameSpeed(); // 3 seconds
  }
  else
  {
    if (turnOffVolumeGuiCounter > 0)
    {
      turnOffVolumeGuiCounter--;
      if (turnOffVolumeGuiCounter <= 0)
      {
        GUIOff(VOLUME);
      }
    }
  }
}


And similarly for TEXTSPEED.
Title: Re: rep_ex_always and a Timer
Post by: monkey0506 on Tue 29/03/2005 17:58:48
I'll try that when I get home...I'm presuming that I would set turnOnVolumeGUI to 1 when I turn it on(?).  Thanks for the help.