wait (var time);
Pauses the current function for a number of frame cycles or seconds.
Resumes
other functions inbetween.
Parameters:
time - number of frames when positive, time
in
seconds when negative (-60 .. +1000).
Speed:
Medium
Remarks:
- Wait temporarily terminates
the function (like return), stores its local
variables and the my and you pointer,
stores the function
state in an internal list (Scheduler List), and
returns to the calling function (if any). After the wait time,
the local variables and the my and you pointers are restored and
the function
is resumed, starting with the line following wait.
- While a function is waiting, all
other functions - including the calling function - continue to run, so all
global variables and all pointers except my and you can
change during the wait time.
- wait(1) is often
used at the end of a while loop which is to be executed once per frame
cycle.
- The
shortest wait time is one frame
cycle, the longest wait time is one minute. If you want to wait even
longer, use a loop.
-
Waiting functions are stored on the Scheduler List in the
order of their last wait() execution. This order can be modified by the proc_mode variable
(lite-C) resp. the proc_late function (C-Script).
Examples:
// let an entity light up for half a second, and then rotate it permanently
action rotator()
{
my.ambient = 100; // increase brightness
wait(-0.5); // wait 0.5 seconds
my.ambient = 0; // normal brightness
while (1) {
my.pan += 3*time_step; // rotate entity by 3 degrees per tick
wait(1); // wait one frame, then repeat
}
}
See also:
return, time_step, timer
► latest
version online