Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: tor.brandt on Wed 16/11/2016 16:59:41

Title: Timer doesn't work with timer ID 1?
Post by: tor.brandt on Wed 16/11/2016 16:59:41
I have this code in my room script:
Code (ags) Select
function room_FirstLoad()
{
  SetTimer(2, 100);
}

function room_RepExec()
{
  if (IsTimerExpired(2))
  {
    cSoundEffects.SayBackground("RIIING RIIING");
  }
}


If I change "2" to "1" (i.e. if I use timer ID 1 instead of ID 2, it doesn't work.
What could be the cause of this?

PS. I'm using a couple of modules I didn't write myself, but I've searched through them and they have no instances of "timer", so I take it they are not occupying timer 1 for some other purpose...
Title: Re: Timer doesn't work with timer ID 1?
Post by: Slasher on Wed 16/11/2016 18:17:35
QuoteI'm using a couple of modules I didn't write myself, but I've searched through them and they have no instances of "timer", so I take it they are not occupying timer 1 for some other purpose...
The Floating Hotspot module uses Timer 1 so there could be one tucked away somewhere...
Title: Re: Timer doesn't work with timer ID 1?
Post by: Cassiebsg on Wed 16/11/2016 18:24:48
To make sure, you can right click above the "SetTimer" and select "Find all usages of SetTimer".
That should show you how many there are in your project.

Wish I could name the timers instead of using numbers though.
Title: Re: Timer doesn't work with timer ID 1?
Post by: tor.brandt on Wed 16/11/2016 18:48:02
Thanks for the replies!

I'll check those things when I get home.
And yeah, it would be nice if the timers could be inherently named, although I guess it would be fairly easy to name the timers in some custom way...
Title: Re: Timer doesn't work with timer ID 1?
Post by: Crimson Wizard on Wed 16/11/2016 18:52:35
As with any other numbers, you can define constants to be able to distinguish them easier:
Code (ags) Select

#define TIMER_FOR_SOME_ACTION 2

<...>

SetTimer(TIMER_FOR_SOME_ACTION, 100);