Skip to main content

Script Engine

Run / stop / inspect arbitrary Lua against any client. Use this when the parent script wants to spin up child scripts on other bots and watch them.

The engine is a singleton per bot id — every client:scripting() call against the same client returns the SAME handle, so two sibling scripts can read each other's :running() / :error() state.

local client = getClient()
local scriptEngine = client:scripting()

scriptEngine:execute(script) -- async; check :running() / :error()
scriptEngine:stop() -- check :running()
scriptEngine:running() -- bool
scriptEngine:get() -- the source currently associated
scriptEngine:error() -- last error, if any

Constructor

client:scripting()

FieldType
Signature(self: Client) → Scripting
ReturnsScripting — the per-bot script engine handle (singleton per bot id)
Asyncno

Methods

scripting:execute(source)

FieldType
Signature(self: Scripting, source: string) → ()
Returnsnothing
Common errors"script already running" (a previous :execute() is still in flight)
Asyncno — returns immediately; the script runs on a detached task

Compile + run source on a fresh SeraphRuntime. Globals/console don't leak between runs. Call :stop() first if a previous run is still in flight.

local engine = client:scripting()
engine:execute([[
print(getClient().username, "ready")
-- ... per-bot routine
]])

scripting:stop()

FieldType
Signature(self: Scripting) → ()
Returnsnothing
Asyncno

Cooperatively cancel + abort the in-flight script (if any). Idempotent — safe to call when nothing is running.

scripting:running()

FieldType
Signature(self: Scripting) → boolean
Returnsbooleantrue iff a script is currently executing
Asyncno

scripting:get()

FieldType
Signature(self: Scripting) → string
Returnsstring — the exact source string of the most recent :execute() call. Empty string when nothing has been run yet
Asyncno

scripting:error()

FieldType
Signature(self: Scripting) → string?
Returnsstring? — last runtime error from the most recent :execute(); nil when the script ran clean or hasn't been executed
Asyncno

Orchestrate many bots

Combine with getClients() for a parent-script that drives child runs:

for _, b in ipairs(getClients()) do
b:scripting():execute([[
print(getClient().username, "ready")
-- ... per-bot routine
]])
end