Creator · Visual Scripting
Visual Scripting SDK Access
The generated script SDK exposes runtime-backed access to visual scripting variables, exported functions, and custom events.
engine v1.0.234Copy for LLM
Variables
Inside a script dispatch, variables are synchronous because Runtime snapshots the script-state store before the handler runs:
const hp = ctx.script.variables.hp.get();
ctx.script.variables.hp.set(Math.max(0, hp - 10));
Cross-entity access targets another entity's attached script:
ctx.entity("boss")?.script("health")?.variables.hp.set(500);
Exported Functions
Only functions marked exported appear in the generated function host. External runtime clients call them through Runtime command dispatch and receive a promise:
const result = await runtime.invokeScriptFunction(gameId, roomId, entityId, "health", "heal", [25], {
playerSessionId,
clientSeq
});
Runtime rejects calls to missing or non-exported functions.
Custom Events
Events use the existing Runtime room router:
ctx.events.emit("round.started", { round: 1 });
export function onCustomEvent(ctx, event) {
if (event.eventKey !== "round.started") return;
ctx.log("info", "Round started", event.payload);
}
The generated payload type comes from the custom event declaration.