Xqzzy Rcxmcq |
This is a question! How can you do timers in AGI? Does you do something with the clock? An example is the salesman clone launch countdown in SQ2. ??? |
smartguy240 | timers as in actions preformed by the computer in an interpreter like have this stuff move and crap...or like a countdown timer? |
Xqzzy Rcxmcq | I'm talking about countdown timers...I think I know how to move objects with timers already. |
smartguy240 | ok then...sorry Nick, Chirs, and Joel know.... |
Xqzzy Rcxmcq | What I was thinking about was like for every increment for seconds, minutes, etc. for the game's internal clock, the timer counts down one second, minute, etc. |
Kon-Tiki |
If it doesn't have to count down from the clock (the one you get by pressing f6), it's this:
x is the number of seconds you want. This code can be a little buggy. That's because I can't remember the exact variable commands, but you still get the idea. -Kon-Tiki- |
jelleghys |
I would do like this:
x is not the number of seconds, it's the number of logic cycles... I use v100==1 and NOT v100==0 because if you would do that, everything in that block will be executed every cycle, until v100 is given another value... The program will go like this: * Enter room * first cycle: set v100 the value x v100 = x-1 * second cycle v100 = x-2 * third cycle v100 = x-3 : : : * x-1 th cycle v100 = 1 special stuff will be done * x th cycle v100 = 0 * x +1 th cycle v100 = 0 and so on... |
Xqzzy Rcxmcq | Thanks, Kon-Tiki, thanks, Jelle. I'll have to keep that in mind. It was just kind of confusing. Oh, well. Thanks. |
Andrew_Baker |
I prefer: If (new_room) { timer = 100; reset(timer_start); } if (timer_start) { if (timer == 0) { //Do whatever } else { timer--; } } |
jelleghys | Didn't you forget anything? The if block will never be executed because you reset timer_start when the ego enters the room... ??? |
Andrew_Baker |
Nah, the timer_start can be triggered by any event or command you want. It could be if (said("use","lever") { set(timer_start); } or if (has("widget")) { set(timer_start); } One thing I should have added is reset(timer_start); once the countdown is finished, to prevent an infinite loop. |