Difference between revisions of "Coroutine (API)"

From ComputerCraft Wiki
Jump to: navigation, search
m (Added Link to Coroutine.)
Line 21: Line 21:
 
|-
 
|-
 
|[[coroutine.running]]()
 
|[[coroutine.running]]()
|Returns the coroutine running (nil of it's the main coroutine).
+
|Returns the coroutine running (nil if it's the main coroutine).
 
|-
 
|-
 
|[[coroutine.status]](coroutine)
 
|[[coroutine.status]](coroutine)

Revision as of 05:23, 26 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.

This is for the Coroutine API. For the Coroutine Object, visit Coroutine.

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 if 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.