Difference between revisions of "Coroutine.resume"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
Line 7: Line 7:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
(bool), (multiple) = coroutine.resume(co,...)
 
(bool), (multiple) = coroutine.resume(co,...)
</source>
+
</syntaxhighlight>
  
 
  '''The first time you resume a coroutine, it starts running its body. The values ... are passed as the arguments to the body function. If the coroutine has yielded, resume restarts it; the values ... are passed as the results from the yield. If the coroutine runs without any errors, resume returns true plus any values passed to yield (if the coroutine yields) or any values returned by the body function (if the coroutine terminates). If there is any error, resume returns false plus the error message'''
 
  '''The first time you resume a coroutine, it starts running its body. The values ... are passed as the arguments to the body function. If the coroutine has yielded, resume restarts it; the values ... are passed as the results from the yield. If the coroutine runs without any errors, resume returns true plus any values passed to yield (if the coroutine yields) or any values returned by the body function (if the coroutine terminates). If there is any error, resume returns false plus the error message'''

Latest revision as of 14:26, 13 July 2023

Available since: Gideros 2011.6
Class: coroutine

Description

Starts or continues the execution of coroutine co.

(bool), (multiple) = coroutine.resume(co,...)
The first time you resume a coroutine, it starts running its body. The values ... are passed as the arguments to the body function. If the coroutine has yielded, resume restarts it; the values ... are passed as the results from the yield. If the coroutine runs without any errors, resume returns true plus any values passed to yield (if the coroutine yields) or any values returned by the body function (if the coroutine terminates). If there is any error, resume returns false plus the error message

Parameters

co: (thread) coroutine to start or resume
...: (any) other optional values to pass as results optional

Return values

Returns (bool) true if coroutine ran without errors, false otherwise
Returns (multiple) values provided to coroutine.yield function call