Difference between revisions of "Coroutine (API)"

From ComputerCraft Wiki
Jump to: navigation, search
m
(Created Table containing commands for coroutine API.)
Line 6: Line 6:
 
Coroutine is a default Lua 5.1 API defined [http://www.lua.org/manual/5.1/manual.html#5.2 here].  
 
Coroutine is a default Lua 5.1 API defined [http://www.lua.org/manual/5.1/manual.html#5.2 here].  
 
Please list any non-working functions here.
 
Please list any non-working functions here.
 +
 +
==Methods==
 +
{| border="1" cellpadding="2" cellspacing="0"
 +
!style="background:#EEE" width="200px"|Method name
 +
!style="background:#EEE" width="*"|Description
 +
|-
 +
|[[coroutine.create]](function)
 +
|Creates and Returns a new coroutine.
 +
|-
 +
|[[coroutine.resume]](coroutine, [var1], [var2], ...)
 +
|Starts or Resumes an already-made coroutine.
 +
|-
 +
|[[coroutine.running]]()
 +
|Returns the coroutine running (nil of it's the main coroutine).
 +
|-
 +
|[[coroutine.status]](coroutine)
 +
|Returns the status of the given coroutine.
 +
|-
 +
|[[coroutine.wrap]](function)
 +
|Creates and Returns a new coroutine in the form of a function.
 +
|-
 +
|[[coroutine.yield]]([var1], [var2], ...)
 +
|Pauses the coroutine. Variables passed will be extra variables next time the coroutine starts.
 +
|}
 +
  
 
==List of non-working functions==
 
==List of non-working functions==
 +
 +
List any non-working functions here.
  
 
[[Category:APIs]]
 
[[Category:APIs]]

Revision as of 16:55, 13 November 2012

Bug

From ComputerCraft 1.3 this API suffers from the problem of potentially spawning Java threads that live forever therefore, use of coroutines should be minimized. This is fixed in ComputerCraft 1.32+, though.

Coroutine is a default Lua 5.1 API defined here. Please list any non-working functions here.

Methods

Method name Description
coroutine.create(function) Creates and Returns a new coroutine.
coroutine.resume(coroutine, [var1], [var2], ...) Starts or Resumes an already-made coroutine.
coroutine.running() Returns the coroutine running (nil of it's the main coroutine).
coroutine.status(coroutine) Returns the status of the given coroutine.
coroutine.wrap(function) Creates and Returns a new coroutine in the form of a function.
coroutine.yield([var1], [var2], ...) Pauses the coroutine. Variables passed will be extra variables next time the coroutine starts.


List of non-working functions

List any non-working functions here.