Author Topic: Timers in AGI  (Read 2998 times)

0 Members and 1 Guest are viewing this topic.

Offline Xqzzy Rcxmcq

Timers in AGI
« 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.  ???


Pathfinder. After I finish CIMS 2004.

Offline Patrick

Re:Timers in AGI
« Reply #1 on: November 30, 2002, 04:16:20 PM »
timers as in actions preformed by the computer in an interpreter like have this stuff move and crap...or like a countdown timer?


Offline Xqzzy Rcxmcq

Re:Timers in AGI
« Reply #2 on: November 30, 2002, 04:29:16 PM »
I'm talking about countdown timers...I think I know how to move objects with timers already.
Pathfinder. After I finish CIMS 2004.

Offline Patrick

Re:Timers in AGI
« Reply #3 on: November 30, 2002, 04:56:41 PM »
ok then...sorry Nick, Chirs, and Joel know....


Offline Xqzzy Rcxmcq

Re:Timers in AGI
« Reply #4 on: November 30, 2002, 05:04:20 PM »
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.
Pathfinder. After I finish CIMS 2004.

Kon-Tiki

  • Guest
Re:Timers in AGI
« Reply #5 on: November 30, 2002, 05:27:38 PM »
If it doesn't have to count down from the clock (the one you get by pressing f6), it's this:
Code: [Select]
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-

Offline Jelle

Re:Timers in AGI
« Reply #6 on: November 30, 2002, 06:00:21 PM »
I would do like this:

Code: [Select]
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...
« Last Edit: November 30, 2002, 06:05:36 PM by Jelle »
Politics is supposed to be the second-oldest profession. I have come to realize that it bears a very close resemblance to the first.

Offline Xqzzy Rcxmcq

Re:Timers in AGI
« Reply #7 on: November 30, 2002, 06:33:13 PM »
Thanks, Kon-Tiki, thanks, Jelle. I'll have to keep that in mind. It was just kind of confusing. Oh, well. Thanks.
Pathfinder. After I finish CIMS 2004.

Offline Andrew_Baker

Re:Timers in AGI
« Reply #8 on: December 01, 2002, 05:06:38 AM »
I prefer:

If (new_room) {

    timer = 100;
     reset(timer_start);

}

if (timer_start) {
    if (timer == 0) {
        //Do whatever
    }
     else {
            timer--;
     }
}
I hope you realize that one day I will devour the Earth.

Offline Jelle

Re:Timers in AGI
« Reply #9 on: December 01, 2002, 08:32:45 AM »
Didn't you forget anything? The if block will never be executed because you reset timer_start when the ego enters the room... ???
Politics is supposed to be the second-oldest profession. I have come to realize that it bears a very close resemblance to the first.

Offline Andrew_Baker

Re:Timers in AGI
« Reply #10 on: December 01, 2002, 09:22:20 AM »
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.
I hope you realize that one day I will devour the Earth.


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.048 seconds with 21 queries.