-
Notifications
You must be signed in to change notification settings - Fork 6
Lua runtimes
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 is a fork of LuaJ with several features added and many fixed bugs.
Cobalt can be setting Computer.runtime=cobalt The custom timeout handler can be enabled with Computer.timeoutError.
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.
Cobalt passes many more of Lua's tests than conventional LuaJ meaning many programs can be run without modification under Cobalt.
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).
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).
Cobalt is 100% thread safe, meaning multiple computers can be run at once. To allow this, see the Multi-threading documentation.