# 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`.
`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.

```lua
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`,
`require`, `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.

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.
