dev:manual:scripting:protocols

Table of Contents

Read GMCP and MSDP

GMCP and MSDP carry structured data alongside the text received from a MUD. Smudgy negotiates both protocols automatically and exposes their latest values as shared state.

GMCP

import gmcp from "smudgy:state/gmcp";
 
const hp = gmcp.value?.Char?.Vitals?.hp;
 
gmcp.watch("Char.Vitals", (vitals) => {
  console.log(vitals);
});

Each GMCP message produces its own state update, even when it repeats the previous value. Message names match case-insensitively. The built-in GmcpTree type covers common messages; games can add different names and payload shapes.

Use gmcp.onReady() from smudgy:core when code must wait until negotiation completes. gmcp.send() and the module-management methods require the package capability gmcp: send.

See the GMCP API reference.

MSDP

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 your script needs numbers. The built-in MsdpTree type covers common room variables while leaving game-specific variables open.

MSDP support is experimental. See the MSDP API reference.