Page tree
Skip to end of metadata
Go to start of metadata



Introduced in

Version:1.00

Description

Description: Suspends execution of a script until the condition returns true.

If the command is called in a function, the calling script will be suspended as well, as it waits for the function to return.

Unlike the while command, the cycle speed of waitUntil is fairly low (~50 cycles/sec), so it can be run without a sleep statement, and not lock up VBS.

The end condition can be preceded by a script block which will be executed until the condition is fulfilled.

waitUntil will throw a generic error if you run it in an unscheduled environment.

waitUntil {
  hint "Destroy the tank";
  !(alive tank1)
};

An ongoing loop can be exited via the exitWith command:

waitUntil {
  hint "Destroy the tank";
  if (count units group player<2) exitWith {
    hint "Your group is too small to complete the task!";
  };  
  sleep 1;
  !(alive tank1)
};

Syntax

Syntax: waitUntil {condition}
Parameters:
  • condition: Code - Condition that has to return true, for loop to end. Can be preceded by executable code.
Return Value: Nothing

Examples

Examples: Waits until 'tank1' has been destroyed:
waitUntil {not alive tank1}
Waits until less than 3 OPFORs are left:
waitUntil {
  _count = {side _x==east}count allUnits;
  hint format["%1 OPFORs left",_count];
  _count < 3
}; 

Additional Information

See also: while, exitWith, Control Structures
Multiplayer: 
Problems: 

Notes



Posted on April 2, 2010 - 17:10
Roehre
If WaitUntil uses an undefined call code, WaitUntil won't release, even when this code is separated from other conditions through or. Be warned that this won't cause an error message.