Skip to main content

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.

caution

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.

tip

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, utf8fully available
oswithout execute, exit, remove, rename, setlocale, tmpname, getenv
debugread-only part only: traceback and getinfo work, anything that changes state does not
ioServer only

Not available:

  • coroutine, superseded by the Thread API, which is built on it
  • package and require. There is no module loader; list every script in the meta file instead
  • dofile and loadfile

Squirrel

Available:

Library
string, mathfully available
io, systemServer only
timeClient 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:

warning

Do not assign to exports or Timer. They are ordinary globals, so overwriting one breaks it for every script in the resource.