Wait

From LuaSTG Wiki
Jump to navigation Jump to search
Wait
Taskwait.png
Task wait icon
Location Task Tab

This function will allow you to pause the execution of a Task for a period of time.

Unit[edit | edit source]

The function accepts a single parameter of type number, the unit of this parameter is frame (1/60 seconds). If you fill 60 into the text area, it means that from here, the task will do nothing in 60 frames (1 sec). After 1 second, the task will continue execution where it was left off.

Example of Use[edit | edit source]

Here are some examples about how to use wait to control the timing of one or more things that happen in parallel.

Example 1[edit | edit source]

We start by a simple example of using wait to control the interval of bullet spawns.

Wait and Bullet Spawn.png

In this way the first bullet will be shot as soon as the boss moves to its default position, and the second one will be shot 60 frames after that.

This node will be translated to a call to task.Wait function when the script is run.

Example 2[edit | edit source]

Move on to the second example.

Wait Example 2.png

We see that this is the same thing as example 1, but with an additional task created right after the first bullet is spawned. The new task controls boss movement, and is actually running in parallel to the outside task that created this new task. Sixty frames after the first bullet is shot, the boss will wander once. However, since the outside task is executing at the same time and 60 frames have passed, the second bullet will be fired at the same time.