Coroutine.wrap

From ComputerCraft Wiki
Jump to: navigation, search
Grid Redstone.png  Function coroutine.wrap
Creates a new coroutine and wraps it in a function. The coroutine itself is created similarly to coroutine.create, but is not made visible to the caller. Calling the function returned by coroutine.wrap is equivalent to calling coroutine.resume on the underlying coroutine, with any parameters passed to the wrapper function being passed in turn to coroutine.resume. Should coroutine.resume return success (that is, its first return value be true), the wrapper function will return the rest of the return values (that is, the parameters the wrapped coroutine’s body passed to coroutine.yield or returned at the end of the function); should coroutine.resume return failure (that is, its first return value be false), the wrapper function will reraise the error and propagate it to the caller.
Syntax coroutine.wrap(function f)
Returns function coroutine wrapper
Part of ComputerCraft
API Coroutine

Examples

Please see Coroutine (API) for a worked example of using all the coroutine functions.