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()
| Field | Type |
|---|---|
| Signature | (self: Client) → Scripting |
| Returns | Scripting — the per-bot script engine handle (singleton per bot id) |
| Async | no |
Methods
scripting:execute(source)
| Field | Type |
|---|---|
| Signature | (self: Scripting, source: string) → () |
| Returns | nothing |
| Common errors | "script already running" (a previous :execute() is still in flight) |
| Async | no — 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()
| Field | Type |
|---|---|
| Signature | (self: Scripting) → () |
| Returns | nothing |
| Async | no |
Cooperatively cancel + abort the in-flight script (if any). Idempotent — safe to call when nothing is running.
scripting:running()
| Field | Type |
|---|---|
| Signature | (self: Scripting) → boolean |
| Returns | boolean — true iff a script is currently executing |
| Async | no |
scripting:get()
| Field | Type |
|---|---|
| Signature | (self: Scripting) → string |
| Returns | string — the exact source string of the most recent :execute() call. Empty string when nothing has been run yet |
| Async | no |
scripting:error()
| Field | Type |
|---|---|
| Signature | (self: Scripting) → string? |
| Returns | string? — last runtime error from the most recent :execute(); nil when the script ran clean or hasn't been executed |
| Async | no |
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