Garry's Mod Wiki


Coroutines are similar to threads, however they do not run simultaneously. They offer a way to split up tasks and dynamically pause & resume functions.


thread coroutine.create( function func )
Creates a coroutine of the given function.
boolean, vararg coroutine.resume( thread coroutine, vararg args )
Resumes the given coroutine and passes the given vararg to either the function arguments or the coroutine.yield that is inside that function and returns whatever yield is called with the next time or by the final return in the function.
thread coroutine.running()
Returns the active coroutine or nil if we are not within a coroutine.
string coroutine.status( thread coroutine )
Returns the status of the coroutine passed to it, the possible statuses are "suspended", "running", and "dead".
coroutine.wait( number duration )
Yields the coroutine for the given duration before continuing. This only works inside a coroutine. This function uses CurTime instead of RealTime.
function coroutine.wrap( function coroutine )
Returns a function which calling is equivalent with calling coroutine.resume with the coroutine and all extra parameters. The values returned by the returned function only contain the values passed to the inner coroutine.yield call and do not include the no error status that coroutine.resume provides. In case of failure, an error is thrown instead.
vararg coroutine.yield( vararg returnValue )
Pauses the active coroutine and passes all additional variables to the call of coroutine.resume that resumed the coroutine last time, and returns all additional variables that were passed to the previous call of resume.

Page Links

Special Pages



Render Time: 27ms

DB GetPage 2
Generate Html 2
SaveChanges (1) 9
Render Body 0
Render Sidebar 12