Difference between revisions of "Coroutine.yield"

From ComputerCraft Wiki
Jump to: navigation, search
(Added Page)
 
(Remove example that doesn’t show anything interesting on its own, improve description, and fix wrong argument list)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
{{Function
 
{{Function
 
|name=coroutine.yield
 
|name=coroutine.yield
|args=[[coroutine]], var1, var2, ...
+
|args=[var1], [var2],
 
|api=Coroutine
 
|api=Coroutine
 +
|returns=[var3], [var4], …
 
|addon=ComputerCraft
 
|addon=ComputerCraft
|desc=Pauses a coroutine.
+
|desc=Pauses the currently executing coroutine and passes control to its parent. The parent is the coroutine that started this coroutine by calling [[coroutine.resume]] on it. The parent regains control by [[coroutine.resume]] returning; the child becomes suspended (and can therefore be resumed by [[coroutine.resume]]). If parameters <var>var1</var>, <var>var2</var>, etc. are passed, those values appear in the return value from [[coroutine.resume]] in the parent. If the call to [[coroutine.resume]] that next resumes the child coroutine has parameters, those parameters are returned from the call to this function.
|examples=
+
|examples=Please see [[Coroutine (API)]] for a worked example of using all the coroutine functions.
{{Example
+
|desc=Pauses the coroutine ''d''.
+
|code=coroutine.yield(d)
+
}}
+
 
}}
 
}}
 +
 +
[[Category:Lua_Core_Functions]]

Latest revision as of 18:24, 22 April 2013

Grid Redstone.png  Function coroutine.yield
Pauses the currently executing coroutine and passes control to its parent. The parent is the coroutine that started this coroutine by calling coroutine.resume on it. The parent regains control by coroutine.resume returning; the child becomes suspended (and can therefore be resumed by coroutine.resume). If parameters var1, var2, etc. are passed, those values appear in the return value from coroutine.resume in the parent. If the call to coroutine.resume that next resumes the child coroutine has parameters, those parameters are returned from the call to this function.
Syntax coroutine.yield([var1], [var2], …)
Returns [var3], [var4], …
Part of ComputerCraft
API Coroutine

Examples

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