P

PlayMUD.online

GMCP

Structured MUD Data

Use GMCP packages directly as Lua variables.

PlayMUD.online negotiates Telnet GMCP, validates its JSON payloads, and exposes the latest package data to every Lua trigger, alias, and lifecycle script.

Reading Packages

local hp = gmcp.Char.Vitals.hp
local maximum = gmcp.Char.Vitals.maxhp

if hp and maximum then
  echo("<green>HP: " .. hp .. "/" .. maximum)
end

Dots in a package name become nested Lua tables. For example, Char.Vitals becomes gmcp.Char.Vitals. JSON objects become tables, arrays become numbered tables, and numbers and booleans keep their types.

GMCP data is read-only. Copy values into persistent profile variables, temporary state, or local variables when a script needs to change them.

Using Updates

local vitals = gmcp.Char and gmcp.Char.Vitals
if vitals then
  state.hp = vitals.hp
  state.maxhp = vitals.maxhp
end

Lua triggers and Lua aliases can read the latest gmcp snapshot whenever they run. Enabled Scripts can define helper functions that read gmcp, and onGMCP(package, data) receives live package updates while the script owns active automation.

The Inspector tab and /print_var gmcp command are useful for finding exact package paths.

Detached Sessions

PlayMUD.online keeps the newest accepted value for each GMCP package while the browser is detached. Returning restores that snapshot for Lua to read. Restored packages do not trigger onGMCP(); it receives new live updates.

Availability

Package names and fields are defined by the connected MUD. Always check that an intermediate table or value exists before using optional packages. PlayMUD.online currently advertises common Core, Char, Char.Vitals, Char.Items, Char.Skills, Room, Comm, and Group packages and also accepts other valid packages within its data limits.

A MUD session retains up to 256 distinct packages and 512 KiB of GMCP state. Malformed messages and updates that exceed the data limits are ignored, so an existing value can remain unchanged. Use Inspector to check which values are currently available.

The client also ignores unsafe package names or fields and excessively nested data, including when restoring a session. An ignored live update does not call onGMCP() or replace the last accepted value. If expected data is missing, check the package in Inspector and ask the MUD operator to check the update.