Gessa Docs
Creator · Visual Scripting

Guide

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:

TypeScript
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:

TypeScript
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:

TypeScript
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:

TypeScript
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.

Was this helpful?Report an issueContact support

On this page