Skip to content

Sandbox & Limits ​

Lua chip scripts run in a deterministic sandbox to ensure game stability and prevent abuse.

Instruction Limits ​

PhaseBudget
Initialization (module-level code)500,000 instructions (default)
Per tick (coroutine + tick + events)50,000 instructions (default)

In the StationeersLua mod configuration (BepInEx / in-game mod panel), category [Lua VM]:

SettingDefaultNotes
InitInstructionLimit500000Startup budget (module-level code, first resume, legacy serialize/deserialize hooks)
TickInstructionLimit50000Per game tick, per chip

Values are clamped between 1,000 and 100,000,000. Only the simulation host runs Lua chips (dedicated server or session host), so in multiplayer these settings apply from the host or server config, not from joining clients.

Exceeding limits triggers a runtime error on the chip (red light on the housing).

ic.persist size limits ​

Category [Lua Persist] in the same mod configuration panel:

SettingDefaultRange
MaxKeyLength1281 - 4096
MaxValueLength81921 - 1,048,576
MaxTotalBytes32768256 - 4,194,304

Server-authoritative (same host rule as instruction limits). See Save/Load Persistence.

Available Libraries ​

LibraryNotes
mathFull: math.sin, math.floor, math.random, etc.
stringFull: string.format, string.sub, string.find, etc.
tableFull: table.insert, table.remove, table.sort, etc.
coroutineFull: coroutine.create, coroutine.resume, coroutine.yield, etc. sleep/yield work inside user coroutines.
utf8UTF-8 string handling
os.clockHigh-resolution timer
os.timeCurrent Unix timestamp
os.dateDate/time formatting
os.difftimeTime difference
pcall, xpcallProtected calls
tonumber, tostring, typeStandard conversions
pairs, ipairs, nextTable iteration
select, unpack, rawget, rawsetTable utilities
loadDynamic code loading (from strings only)
util.jsonJSON encode/decode

Blocked Libraries ​

BlockedReason
debugIntentionally unavailable on chips - the Lua debug library exposes internal VM state and is not available in the chip sandbox
ioFilesystem access
packageFilesystem module loading (replaced by require() from data network)
dofile, loadfileFilesystem access
os.execute, os.exit, os.remove, os.renameProcess/filesystem mutation
os.tmpname, os.setlocale, os.getenvSystem interaction

Runtime Behavior ​

  • Scripts run as Lua coroutines, allowing sleep() and yield() to pause execution
  • Async C# work during tick is rejected — only coroutine suspension is supported
  • print(...) writes to the Lua Debugger Logs tab (per-chip, bounded, cleared on power cycle)
  • File I/O, module loading, and process-affecting operations are disabled

⚠️ This documentation was AI-generated and may contain inaccuracies. Please submit pull requests with corrections as needed.