Table of Contents

Non-standard Lua Libraries

Most of Lua's standard libraries are available, although some of them may only be available partially or as re-implementations, meaning behavior may differ slightly. Please see the Lua 5.3 manual for documentation on the standard libraries.

Descriptions of “re-implementations” are based on OpenOS. Other custom operating system may have different details.

This page tries to list all differences to these standard libraries.

Basic Functions

The original functions from the base library are available with the following differences.

Coroutine Manipulation

The original functions from the coroutine library are available with no observable differences.

Note that the coroutine.resume and coroutine.yield implementations exposed to user code are wrappers that take care of aborting code that does not yield after a certain time (see config), and to allow differentiating system yields from user yields (system yields “bubble”, for example this is used for the shutdown command and component API calls). This should not be noticeable from user code, however. If it is, it should be considered a bug.

Modules

The package module got a reimplementation for OpenComputers. It should operate the same as the original, but is lacking the following functions:

The latter two are missing because it is impossible to load C code in OpenComputers.

require is a method available in the global scope, i.e. no module loading is required to have access to it, you can use it on the first line of your scripts (which is commonly the case). Its interworkings depend on the package library so a description of it is appropriate here.

String Manipulation

The original functions from the string library are available without alterations.

Note that the functions of the GPU API work on UTF-8 strings, and, by extension, so does term.write and print. To help you work with UTF-8 strings, there is an additional library, the Unicode API.

Table Manipulation

The original functions from the table library are available without alteration.

Mathematical Functions

The original functions from the math library are available with minor alterations.

Bitwise Operations

The original functions from the bit32 library are available without alteration.

Input and Output Facilities

The original functions from the io library have been reimplemented for the most part, and work on mounted filesystem components. Standard input is read by io.read (as well as term.read and io.stdin:read). Standard ouput is written to by io.write (as well as term.write, io.stdout:write, and print). Standard error is written to by io.stderr:write.
For the most part these should be functionally equivalent to the standard Lua implementation. They may return error strings that differ from vanilla Lua, though, but since that uses C library errors for the most part, which are platform dependent, it's not a very good idea to use these for program logic anyway.

snippet.lua
io.stdin:read() -- read from std in
io.read() -- also read from std in
term.read() -- also read from std in
snippet.lua
io.stdout:write("write to stdout")
io.write("also write to stdout")
term.write("also write to stdout, but wraps text if the string is longer than the width of the screen resolution allows")
snippet.lua
io.stderr:write("error text to stderr")

Operating System Facilities

The original functions from the os library have been partially reimplemented.

One additional function has been added: - os.sleep(seconds: number) which allows pausing a script for the specified amount of time. os.sleep consumes events but registered event handlers and threads are still receiving events during the sleep. Rephrased, signals will still be processed by event handlers while the sleep is active, i.e. you cannot pull signals that were accumulated during the sleep after it ended, since no signals will remain in the queue (or at least not all of them).

Some new functions that kind of fall into this category are available in the computer API.

Debug

Only debug.traceback and debug.getinfo (since 1.5.9), which is limited only to passive info, are implemented.

Contents