Wait

Function

Syntax

Pauses the current code for a number of seconds of game time. The Engine keeps drawing frames during the wait.

Wait(<seconds>)

Parts

<seconds>The length of the wait in seconds. Decimals are accepted: 0.5 is half a second.

Good to know

  • It counts game time: it stops while the game is paused and follows the time scale.
  • Wait counts seconds, Sleep() counts milliseconds. In DarkBASIC WAIT counts milliseconds: here Wait(1000) lasts about 16 minutes.
  • Refused inside a FUNCTION and after the top-level LOOP. Allowed before DO, inside the loop, in a straight program and in a label.
  • It is a statement. x = Wait(1) compiles, then the program stops on that line with Wait is not defined.
  • In a program without DO, one Wait() anywhere, even in a label, turns the whole program into a single main program: lifecycle functions such as update are no longer found.
  • Inside a task, it is a point where CANCELTASK stops the task.

Example

Console("3")      ' 3Wait(1)Console("2")      ' 2Wait(0.5)Console("go")     ' go
In the manual : The game loop and tasks

Commands that go with it