parallel.waitForAny
From ComputerCraft
Jump to navigation
Jump to search
parallel.waitForAny Function | |
---|---|
Syntax parallel.waitForAny(
| |
Returns | nil |
API | parallel |
Source | CC:Tweaked (source) |
Switches between execution of the functions, until any of them finishes. If any of the functions errors, the message is propagated upwards from the parallel.waitForAny call.[1]
|
|||
Do nothing until the user presses a key or 10 seconds have elapsed. | |||
Code | parallel.waitForAny(
function()
local ev
repeat
ev = coroutine.yield()
until ev == 'key'
end,
function() sleep(10) end
)
print("Goodbye!")
|
||
Output | Prints Goodbye! after either 10 seconds or the user presses a key. |
References
- ↑ "CC-Tweaked/parallel.lua". GitHub. 2017-06-12. Retrieved 2018-08-06.