| Wait Until () | |
wait until <> | |
| Category | Control |
| Type | Stack |
| Introduced in | 08Dec03 (0.x) |
The Wait Until () block is a Control block and a Stack block. The block pauses its script until the specified boolean condition is true.
Example Uses
As the block pauses its script until a condition is true, it is mainly used when a script must wait for a certain event. Some common uses include:
- Waiting for a sprite to move somewhere
wait until < ( [x position v] of (Sprite1 v) ) > [50] >
- Waiting for a variable to reach a certain number
wait until < ( meter ) = [10] >
- Waiting for a reply from another script or sprite
wait until < ( ready? ) = [1] >
It can also be used to detect if the mouse-pointer is released when touching a sprite:
when gf clicked
forever
wait until <mouse down?>
wait until <not <mouse down?>>
if <touching (mouse-pointer v)?> then
. . . //This code will execute if the mouse-pointer is released while touching the sprite.
end
end
Workaround
- Main article: List of Block Workarounds
This block can be replicated with an empty Repeat Until () block:
repeat until < . . .:: grey> end
The C insert is left empty; nothing is occurring while the block waits.