---
title: "Visual Scripting SDK Access"
description: "The generated script SDK exposes runtime-backed access to visual scripting variables, exported functions, and custom events."
engineVersion: v1.0.234
date: 2026-09-28
license: "(c) Gessa, proprietary. Cite with attribution to https://gessa.ai/docs/. Terms: https://gessa.ai/terms/."
canonical: https://gessa.ai/docs/creator/visual-scripting-sdk-access/
---
# Visual Scripting SDK Access

The generated script SDK exposes runtime-backed access to visual scripting
variables, exported functions, and custom events.

## Variables

Inside a script dispatch, variables are synchronous because Runtime snapshots
the script-state store before the handler runs:

```ts
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:

```ts
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:

```ts
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:

```ts
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.
