Timer Lua Module

From Hopmod Wiki

Jump to: navigation, search

timer.create()

Create and return a timer object.

timer:async_wait(callback)

Call the callback when the timer expires.

timer:cancel()

Cancel the deadline. Any waiting callbacks are called with an error message argument.

timer:expires_at(time)

Set the deadline.

Example: timerObj:expires_at(os.time() + 5) -- expire in 5 seconds starting from now

timer:expires_from_now(milliseconds)

Set the deadline.

Example: timerObj:expires_from_now(5000) -- expire in 5 seconds starting from now