ScriptWait

void ScriptWait (int script);

Usage

Delays the script it is contained within until the script specified by script has completed execution. If the specified script is not running, this command will wait until it has run. For named scripts, use NamedScriptWait.

Parameters

  • script: The script number to wait for.

Examples

The advantage of ScriptWait is that it can hold a once-only script. Say there was a script which is to be run only once to open a door (for example it activates when the player destroys a control panel which can only be done once), but the map requires the door to be unlocked previously to this. In the event that the door is still locked, ScriptWait can be used to hold the once-only script until the script that unlocks the door has started and finished.

An example implementation of this code follows. It is rather lengthy, but fairly straightforward.

bool locked = TRUE;
script 1 (int sector)
{
    if (locked)
    {
        Print (s:"Security access required!");
        ScriptWait (2);
    }

    Door_Open (sector, 20);
}
 
script 2 (int count)
{
    while (count > 0)
    {
        HudMessage (i:count--; HUDMSG_PLAIN, 1,
            CR_RED, 0.05, 0.95, 1.0);
        Delay (1);
    }

    HudMessage (s:"Verified!"; HUDMSG_PLAIN, 1,
        CR_GOLD, 0.05, 0.95, 1.0);
	
    locked = FALSE;
}

The first script is the once-only script. If the door is locked, it tells the user and waits for the unlock script to run and finish. After that, or if the door was already unlocked, the door opens.

The second script takes a parameter, which is the amount of frames to count before unlocking. Note that count is displayed as count--, where the two minus signs are the decrement operator. After the count is up, the door is unlocked.

Script functions
ACS_ExecuteACS_NamedExecute
ACS_ExecuteWaitACS_NamedExecuteWait
ACS_ExecuteAlwaysACS_NamedExecuteAlways
ACS_ExecuteWithResultACS_NamedExecuteWithResult
ACS_LockedExecuteACS_NamedLockedExecute
ACS_LockedExecuteDoorACS_NamedLockedExecuteDoor
ACS_SuspendACS_NamedSuspend
ACS_TerminateACS_NamedTerminate
ScriptWaitNamedScriptWait
FS_ExecuteUsePuzzleItem
This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.