Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Gepard on Mon 03/09/2007 23:47:32

Title: IsTimerExpired function not working
Post by: Gepard on Mon 03/09/2007 23:47:32
function repeatedly_execute()
  {
  if (IsTimerExpired(1) == 1) {
output.Text="MESSAGE";
SetGlobalInt(2, 1);
}

  if (IsTimerExpired(2) == 1) {
  PlaySound (1);
  Wait (20);
  Display ("Email!");
  player.AddInventory (imail1);
  SetGlobalInt(10, 3);
}

  if (IsTimerExpired(3) == 1) {
  PlaySound (1);
  Wait (20);
  Display ("Email!");
  player.AddInventory (imail2);
}

  if (IsTimerExpired(4) == 1) {
  PlaySound (1);
  Wait (20);
  Display ("Email!");
  player.AddInventory (imail3);
}

  if (IsTimerExpired(5) == 1) {
    PlaySound (1);
    Wait (20);
    Display ("Email!");
    player.AddInventory (ieles);
}
}

I have this in my script. The game save it without any problems, but than when the timer expires, nothing happens.
Title: Re: IsTimerExpired function not working
Post by: Gilbert on Tue 04/09/2007 01:04:39
The problem is, where and when did you start the timers?
You must start the timers with SetTimer() (read the manual for details), otherwise theyu won't expire.
Title: Re: IsTimerExpired function not working
Post by: Gepard on Tue 04/09/2007 14:06:47
Here:

function write_Click(GUIControl *control, MouseButton button) {
  if (mail.Text!="") {
String input=String.Format("%s", mail.Text);

if (input=="scheme") {
  if (GetGlobalInt(16)==0) {
  email.Text="MESSAGE";
  SetTimer (5, 200);
  SetGlobalInt (16, 1);
}
}
...

And I tried almost everything. Setting the timer for just 20, 2, 500, nothing works.
Title: Re: IsTimerExpired function not working
Post by: Ashen on Tue 04/09/2007 14:17:40
Does the other stuff (e.g. change email.Text and GI16) with the SetTimer command work? If not, do you change GI16 anywhere else? Try adding a few Display commands to the conditions, to check at what point it stops working.

I don't think you need to use the input String, and even if you'd rather use it, String.Format isn't needed:


String input = mail.Text;


Or if you don't mind typing (or pasting) mail.Text a few more times:

if (mail.Text!="") {
  if (mail.Text=="scheme") {
    if (GetGlobalInt(16)==0) {
      email.Text="MESSAGE";
      SetTimer (5, 200);
      SetGlobalInt (16, 1);
    }
  }
//...

This won't have anything to do with your problem, just pointing it out.