dev:scriptref:msdp

MSDP (experimental)

Generated from smudgy v0.4.2-dev (smudgy-core.d.ts @ 5110ac599715). Index: scriptref.

Read the experimental MSDP structured-data channel as shared state and react to its connection lifecycle events.

import msdp from "smudgy:state/msdp";
 
const roomName = msdp.value?.ROOM?.NAME;
msdp.watch("ROOM", room => console.log(room));

MSDP scalars arrive as strings; parse numeric values where needed. For negotiation and comparison with GMCP, see Read GMCP and MSDP.

Default export

The module's default export (msdp).

const msdp: StateConsumer<MsdpTree>;

The live MSDP tree, one entry per variable name (see MsdpTree): read the latest value with msdp.value, subscribe with msdp.watch(path, ...), and wire widgets with msdp.bind(path). Each server update commits as its own change, so a watcher at or under a variable's path runs once per update.

The variable shapes

MsdpTree

export interface MsdpTree {
  ROOM?: {
    VNUM?: string;
    NAME?: string;
    AREA?: string;
    TERRAIN?: string;
    ENVIRONMENT?: string;
    EXITS?: Record<string, string>;
    COORDS?: { X?: string; Y?: string; Z?: string; [field: string]: unknown };
    [field: string]: unknown;
  };
  ROOM_VNUM?: string;
  ROOM_NAME?: string;
  ROOM_EXITS?: Record<string, string>;
  ROOM_TERRAIN?: string;
  AREA_NAME?: string;
  REPORTABLE_VARIABLES?: string[];
  [variable: string]: unknown;
}

The shape of the MSDP tree (import msdp from "smudgy:state/msdp"), one entry per variable the server reports. MSDP is string-typed on the wire, so every scalar arrives as a string (“14100”, not 14100) — parse numbers where you need them. The well-known room variables are typed; everything else is open. Games document their own variables; narrow the same way as GmcpTree.

  • ROOM — The composite room table (servers that send one): the server's room number, name, area, and an exits map of direction to destination room number.
  • ROOM_VNUM — Flat spellings some servers send instead of (or beside) ROOM.
  • REPORTABLE_VARIABLES — The variables the server can report, sent in reply to the handshake.

Lifecycle events: smudgy:events/msdp

ready

export const ready: EventConsumer<Record<string, never>>;

Fires once MSDP negotiation completes and the room variables have been requested; MSDP data starts flowing from this moment.

closed

export const closed: EventConsumer<Record<string, never>>;

Fires when MSDP stops on a live connection: the server withdrew it, or the connection dropped while it was active. The last-received data stays readable through smudgy:state/msdp.


Script API reference · ← GMCP · smudgy:core — Automations → · Scripting manual