Skip to content
This repository was archived by the owner on Jul 1, 2018. It is now read-only.

Lua runtimes

SquidDev edited this page Jan 22, 2017 · 9 revisions

Vanilla ComputerCraft uses a Lua implementation written in Java known as LuaJ. CCTweaks allows registering and using custom runtimes through the use of the Computer.runtime option. By default this is luaj.

Warning: Custom runtimes are generally stable but if you encounter an issue with CCTweaks or ComputerCraft, please test with the default LuaJ runtime before reporting.

Additional runtimes can be found in the CCTweaks-Runtimes package.

Cobalt

Cobalt is a fork of LuaJ with several features added and many fixed bugs.

Configuration

Cobalt can be setting Computer.runtime=cobalt The custom timeout handler can be enabled with Computer.timeoutError.

Features

Each computer is perfectly sandboxed from the others

LuaJ has a bug where the string metatable is shared across computers. ComputerCraft removes the possibility of this bug being exploited but Cobalt fixes it at the root. This also means the debug library is perfectly safe to use as it cannot touch other computers.

Improved comparability with vanilla Lua

Cobalt passes many more of Lua's tests than conventional LuaJ meaning many programs can be run without modification under Cobalt.

Improved error messages

Calling pront() under Cobalt will include information about the context like vanilla Lua. In this case you would get attempt to call global 'pront' (a nil value).

(Optional) Improved timeout errors

ComputerCraft terminates code if it has been running for too long without yielding. However when you are stuck in an infinite loop which doesn't touch ComputerCraft code (such as while true do end) this error is not processed and so the computer shuts down.

Cobalt adds an option (Computer.timeoutError) to terminate directly after the time has elapsed. This timeout will also occur within some library code (such as long pattern matches).

Multi-threading

Cobalt is 100% thread safe, meaning multiple computers can be run at once. To allow this, see the Multi-threading documentation.

Clone this wiki locally