Delay
From ZDoom Wiki
void Delay (int tics)
Usage
Delays the script for the specified amount of time.
Parameters
- tics
- The amount of time to wait in tics.
Examples
Delay is a very common command. A useful application of it is to stop the 'Runaway script x terminated' error. A script is terminated if it gets stuck in to an indefinite loop (as far as the game can tell). For example:
script 1 ENTER
{
int health;
while (TRUE)
{
health = GetActorProperty (0, APROP_HEALTH);
Print (s:"You have ", d:health, s:" health!");
}
}
This script will cause a runaway error because in will try to tell the player their health without stopping. Adding a slight delay will result in the desired effect, a pointless health update that lasts forever, telling the player their own health.
script 1 ENTER
{
int health;
while (TRUE)
{
health = GetActorProperty (0, APROP_HEALTH);
Print (s:"You have ", d:health, s:" health!");
Delay (1); // Wait for next frame
}
}
The other obvious use is to delay events in a script. For example, the behaviour of the door that is used in the trap for the first key in E1M6 of Doom can be simulated with a script like this:
script 12 (int sector, int speed, int seconds)
{
Door_Close (sector, speed);
Delay (35*seconds);
Door_Open (sector, speed);
}
Although this behaviour can be achieved using Door_CloseWaitOpen anyway.

