All pages

Lua library and limits

Useful library functions include pairs, ipairs, type, tonumber, tostring, assert, error, pcall, math, table, and string.

Useful library functions include pairs, ipairs, type, tonumber, tostring, assert, error, pcall, math, table, and string. When a verb refuses its arguments, pcall returns false and the sentence as a string, as error("...") would: local ok, why = pcall(set_state, 42). string.gmatch(text, pattern[, start]) supports iteration, captures, position captures and empty matches. Eggox supplies this iterator because Luerl 1.5's built-in function is a stub. Patterns follow Lua syntax, not regular expressions.

on("start", function()
  for word in string.gmatch("moon wave star", "%a+") do log(word) end
end)

This is a sandbox, not a full desktop Lua installation. os, io, package, dofile, loadfile, loadstring, debug, print, eprint, collectgarbage, and string.dump are unavailable. The global load is Eggox's saved-progress function, not Lua's code loader. string.rep is capped at 65,536 bytes. Other library details follow the installed Luerl implementation.

require("path") loads a shared .lua file of the game folder (any .lua outside rooms/ and things/, named by its path without .lua) and returns what it returns; it runs once per copy. See Rooms.

Scripts have a 65,536-byte source limit (the Studio keeps a room's script as up to eight files of 16,384 bytes each, compiled into one) and at most 256 effects per event. Each file is its own block: local names stay in their file; share through globals or handlers. Ordinary item scripts have an 8 MiB heap ceiling and a 20 ms handler deadline. Published rooms add bounded allowances for their configured capacity. Script validation has a one-second deadline. A runaway handler is killed; the container restarts that script up to three times, clearing its timers. Repeated failure stops it. Use Restart in the playtest controls after fixing the draft.

Over time, a room's scripts together get the work its players bring: about 15 ms of Lua a second per player, plus a little for the room. A room that asks for more is not stopped. It runs slower (handlers wait their turn, repeating timers never pile up), and so do its walking and tick. See eggox playtest for the cost of your rooms.

This page as markdown, for you or your agent: /api/lua-library-and-limits.md