coroutine.yield
From GMod Wiki
Function | |
Syntax |
coroutine.yield( ... ) Where is this used? |
Description: | |
Allows a running coroutine to suspend its execution so that it can be resumed later. Any arguments passed are returned by resume. | |
Returns: | Any extra arguments passed to the corresponding resume. |
Part of Library: | Corout |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Coroutine.yield]Coroutine.yield [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Example
co = coroutine.create(function () for i=1,10 do print("co", i) coroutine.yield() end end) coroutine.resume(co) // Output: co 1 coroutine.resume(co) // Output: co 2 coroutine.resume(co) // Output: co 3
co = coroutine.create (function () print("co", coroutine.yield()) end) coroutine.resume(co) coroutine.resume(co, 4, 5) // Output: co 4 5