Task
Contains utility functions for writing concurrent code.
Functions
wait(seconds)
Stops executing the current function, until the specified number of seconds have passed.
Parameters
- seconds — The number of seconds to wait.
Example
Write a message in the console after 5 seconds.
function onStart()
Task.wait(5)
Hud.console.write("5 seconds have passed!")
end
yield()
Yields execution of the current function, resuming on the next frame.
Example
Do nothing until counter reach 60 and 120. Then rotates 180 degrees and move forward 2 units respectively.
function onStart()
local counter = 0
while true do
counter = counter + 1
if counter == 60 then
Rotation.turn(2)
end
if counter == 120 then
Movement.moveForward(2)
end
Task.yield()
end
end