scriptref:msdp

MSDP (experimental)

Generated from smudgy v0.4.1 (smudgy-core.d.ts @ 2ee285826109). Index: scriptref.

MSDP is an older structured-data channel some MUDs offer instead of (or alongside) GMCP. Smudgy negotiates it automatically and collects every variable the server reports into one live tree, consumed like any shared state (events). MSDP support is experimental in this release.

import msdp from "smudgy:state/msdp";
 
// The latest value, whenever a script needs it:
const roomName = msdp.value?.ROOM?.NAME;
 
// Runs once per server update at or under the path:
msdp.watch("ROOM", room => { ... });

MSDP is string-typed on the wire: every scalar arrives as a string ("14100", not 14100) — parse numbers where they matter. Each server update commits as its own change, so a watcher at or under a variable's path runs once per update. The well-known room variables are typed on MsdpTree; games document their own variables, and a script narrows them with a cast exactly as GmcpTree shows (gmcp).

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 · smudgy:core — Sessions & output · smudgy:core — Lines & buffer · smudgy:core — Shared state & events · GMCP · smudgy:core — Automations · smudgy:core — Saved automations · smudgy:core — Panes · smudgy:widgets · Mapper · smudgy:params