Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Gepard on Tue 06/01/2009 09:56:03

Title: SkipTimer function?
Post by: Gepard on Tue 06/01/2009 09:56:03
Im posting this here as well, as some people might just visit Technical Forum and not Begginers... I would like to know if it is possible to create a new function: "SkipTimer (int timer, int loops);" Or is there a module for this sort of thing? The thing is I have a timer set to a certain amount of time and after player clicks on a button, I want 4000 loops out of 10000 to expire immediately.
Title: Re: SkipTimer function?
Post by: Gilbert on Tue 06/01/2009 10:01:34
Don't use the internal timers then, use a variable that got its value decremented every game loop in the repeated_execute() or repeated_execute_always() functions. In this way you can modify the variable whenever and in whatever ways you like.
Title: Re: SkipTimer function?
Post by: Gepard on Tue 06/01/2009 10:28:14
Damn! So simple and yet it would never cross my mind. Thank you! However, the SkipTimer function might be a nice feature in the next ags version as you get diferent results using timer and variable. With the timer, the game pauses every time a message is displayed, while with the variable it doesnt.
Title: Re: SkipTimer function?
Post by: Shane 'ProgZmax' Stevens on Tue 06/01/2009 13:04:42
That's because SetTimer (if that's what you're using) will count down once and only once unless released and re-started.  I've never liked SetTimer for this reason, but as Gilb0t says, a variable will do what you need it to do.
Title: Re: SkipTimer function?
Post by: Pumaman on Tue 06/01/2009 19:29:48
Quote from: Gepard on Tue 06/01/2009 10:28:14
With the timer, the game pauses every time a message is displayed, while with the variable it doesnt.

If you put the code in repeatedly_execute it will pause while a message is displayed; if you put it in repeatedly_execute_always then it won't.

Also, please don't double-post threads. You've already asked this question in the Beginners Forum (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=36522); if you don't get an answer there please just ask the moderators to move the thread here rather than creating a duplicate.