Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: on Fri 05/11/2004 08:18:45

Title: repeatedly_execute and timers (SOLVED)
Post by: on Fri 05/11/2004 08:18:45
This is a sequel (don't know the right word for it...) to the "flashing light" -topic. The flashing works, but now I have an other kind of a problem with it. This is my repeatedly_execute -script  for the room:

  // script for room: Repeatedly execute
if (IsTimerExpired(1) == 1) {
  if (GetGlobalInt(150)==0) {
  SetTimer(1,Random(20));
  SetBackgroundFrame(1);
  SetAreaLightLevel(2,0);
  SetGlobalInt(150,1); }
  else {
    SetTimer(1,Random(30));
  SetBackgroundFrame(0);
  SetAreaLightLevel(2,-98);
  SetGlobalInt(150,0); }
}

Now the background changes (=light flashes), but at some point it just stops at some point and doesn't repeat anymore. When I set the randomness(?) higher (for ex. 80), it repeats it with no problems, but I do not want the lights to flash so slowly... So is the bug in my script or is there some restrictions with repeatedly_execute and timers?
Title: Re: repeatedly_execute and timers
Post by: SSH on Fri 05/11/2004 09:26:30
Perhaps you need to have a minimum time between flashes, if your compyetr's framerate isnt high enough. Try changing SetTimer(1,Random(20)); to SetTimer(1,Random(20)+5); and also +5 to the other settimer...

Dunno if this will help,, but I think its worth a try
Title: Re: repeatedly_execute and timers
Post by: on Fri 05/11/2004 10:58:17
It works now, thanks!
Title: Re: repeatedly_execute and timers (SOLVED)
Post by: Pumaman on Fri 05/11/2004 18:16:17
Yes, your problem was that if Random() returned 0, the timer would not be started. Just having a +1 would do the trick.