wait(ms)
wait(ms) pauses execution for the given number of milliseconds.
Syntax
wait(milliseconds);Examples
wait(1000); // pause 1 second
wait(500); // pause 0.5 seconds
wait(3000); // pause 3 secondsUse with loops
wait() is commonly used inside while loops. Time spent waiting does not count toward the loop protection 2-second-per-iteration budget (v0.1.5+):
class App {
let i = 3;
while (i > 0) {
print("tick:", i);
i = i - 1;
wait(2500); // safe — blocked time is excluded
}
}Rules
- Argument must be numeric (milliseconds) — int or float (v0.1.5+)
- Fractional durations work:
wait(0.5)(v0.1.5+) - Negative values throw a runtime error
wait(0)is valid but does nothing
Errors
wait("hello"); // [VDX] wait() expects a number (milliseconds)
wait(-100); // [VDX] wait() duration cannot be negative