K€T4M1NDOCS
INTERNAL / DEVELOPER REFERENCE
Lua development

Runtime and limits

Libraries, state lifetime, execution budgets and output behavior.

Local Lua 5.4

See scripting/scripts.cpp, specifically initialize and execute. Every execution creates a fresh Lua state and closes it on completion. Globals do not persist across separate runs.

Available libraries

Library or functionCurrent behavior
Base, table, string, math, utf8Registered
io, os, package, debug, coroutineNot registered
dofile, loadfile, load, collectgarbageRemoved from the global environment
printCustom implementation writing to the editor output

A local-only example

This example uses only a table and string formatting. No game backend is required.

local palette = { "Galaxy", "Mars", "Aurora" }
for index, name in ipairs(palette) do
    print(string.format("%d: %s", index, name))
end

Execution budgets

BudgetValueMeaning
Lua allocation8 MiBThe custom allocator caps the Lua state.
Deadline250 msChecked by the Lua hook, not a hard interruption of arbitrary C++ calls.
Instructions200,000The hook checks in batches of 1,000 instructions.
Output16,000 bytesOlder text is discarded once the buffer exceeds the limit.

Errors and completion

Load and execution errors are appended to editor output. Budget cancellation reports Script stopped: cancelled or execution budget exceeded. A working local runtime does not demonstrate that the game backend is ready.

K€T4M1N Docs The source is the reference.