parallel.waitForAny

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]

ExampleWait for user interaction or a timeout
Do nothing until the user presses a key or 10 seconds have elapsed.
Code
<nowiki>
parallel.waitForAny(
  function()
    local ev
    repeat
      ev = coroutine.yield()
    until ev == 'key'
  end,
  function() sleep(10) end
)
print("Goodbye!")
</nowiki>
Output Prints Goodbye! after either 10 seconds or the user presses a key.

parallel.waitForAny
Function
Syntax
parallel.waitForAny(
  • functions... : function
)

Returns nil
API parallel
Source CC:Tweaked (source)

References

  1. "CC-Tweaked/parallel.lua". GitHub. 2017-06-12. Retrieved 2018-08-06.
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.