Sandbox & Limits
Resource scripts do not get the full standard library of their language. Anything that reaches outside the game, or that could take the server or a player's game down with it, is either missing or capped. This page lists what is actually there.
Runaway Scripts
A single script call (one thread step, one event handler, one exported function) may run for at most 5 seconds and the VM may use at most 256 MiB of memory. A script that goes over either one is stopped with an error, and the whole resource is shut down: a script that ran away once does it again on the next tick.
This safety net only covers Lua. In a Squirrel script an endless loop that never calls
Thread.Pause will freeze the server, or the game of every player who loaded the resource, and
nothing will step in.
The 5 seconds are per call, not per resource. Long work belongs in a
thread that calls Thread.Pause(0) in its loop: each tick is its own call and
gets its own 5 seconds.
Lua
Available:
| Library | |
|---|---|
base, table, string, math, utf8 | fully available |
os | without execute, exit, remove, rename, setlocale, tmpname, getenv |
debug | read-only part only: traceback and getinfo work, anything that changes state does not |
io | Server only |
Not available:
coroutine, superseded by the Thread API, which is built on itpackageandrequire. There is no module loader; list every script in the meta file insteaddofileandloadfile
Squirrel
Available:
| Library | |
|---|---|
string, math | fully available |
io, system | Server only |
time | Client only |
The blob library is not registered.
Always-Present Globals
Two globals are set up before your scripts run and are part of the API rather than of your resource:
Do not assign to exports or Timer. They are ordinary globals, so overwriting one breaks it for
every script in the resource.