metis.timer
Utilities for working with timers.
timeout(The, fn, ...) | Run a function, waiting for it to complete or for a timer to expire. |
---|
- timeout(The, fn, ...)Source
Run a function, waiting for it to complete or for a timer to expire.
This does not terminate a function which is running. It must yield (e.g. pull an event) in order to be interrupted.
Parameters
- The
number
time (in seconds) the function can run for before begin stopped. - fn
function
The function to run. - ... Arguments to pass to the function.
Returns
- true If the function completes without timing out.
- ... The return values of the function.
Or
- false If the function times out.
Usage
Wait for a "redstone" event for a maximum of 5 seconds.
local timeout = require "metis.timer".timeout timeout(5, os.pullEvent, "redstone")
- The