Community
AGI Programming => Mega Tokyo AGI Archive => Topic started by: Xqzzy Rcxmcq on November 30, 2002, 04:14:26 PM
-
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. ???
-
timers as in actions preformed by the computer in an interpreter like have this stuff move and crap...or like a countdown timer?
-
I'm talking about countdown timers...I think I know how to move objects with timers already.
-
ok then...sorry Nick, Chirs, and Joel know....
-
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.
-
If it doesn't have to count down from the clock (the one you get by pressing f6), it's this:
f(5) {
// rest of the starting code
v100 = x
}
if(v100 != 0) {
v100 --
}
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-
-
I would do like this:
if (f5) { // f5 = new room, you can put any flag here
v100 = x;
}
if (v100 == 1) {
// do your stuff, for when timer ends (alarm), end of countdown... you know
}
v100--;
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...
-
Thanks, Kon-Tiki, thanks, Jelle. I'll have to keep that in mind. It was just kind of confusing. Oh, well. Thanks.
-
I prefer:
If (new_room) {
timer = 100;
reset(timer_start);
}
if (timer_start) {
if (timer == 0) {
//Do whatever
}
else {
timer--;
}
}
-
Didn't you forget anything? The if block will never be executed because you reset timer_start when the ego enters the room... ???
-
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.