Author Topic: Timer not functioning (using CW module) SOLVED  (Read 149 times)

Mr Games

    • I can help with making music
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
Timer not functioning (using CW module) SOLVED
« on: 27 Nov 2018, 21:58 »
Hi guys :grin:

I initially couldn't get the timer to work and found a thread where another user had the same issue.
Here I discovered Crimson Wizard's Timer Module and imported the script. But my timer still isn't working.

Code: Adventure Game Studio
  1. Timer *chickenTimer;
  2.  
  3. function room_AfterFadeIn()
  4. {
  5.   chickenTimer = Timer.StartRT(5.0);
  6.   if (Timer.IsExpired(chickenTimer)) {
  7.   cSmileyface.ChangeRoom(15);
  8.   }
  9. }

I want to change room when the timer expires, but as far as I can tell there's nothing wrong with my code. Am I missing something?
« Last Edit: 27 Nov 2018, 22:29 by Mr Games »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Timer not functioning (using CS module)
« Reply #1 on: 27 Nov 2018, 22:19 »
You need to check for timer expiration in "repeatedly execute" event.

What happens in your code here is this: you create a timer, immediately check it for expiration once (which won't happen since it just started) and leave it.

Mr Games

    • I can help with making music
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
Re: Timer not functioning (using CW module)
« Reply #2 on: 27 Nov 2018, 22:29 »
Another mystery solved! Thank you, now I understand how it works.