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, but Scripts do not receive automatic lifecycle callbacks.

Detached Sessions

The gateway keeps the newest value for each GMCP package while the browser is detached. Returning to PlayMUD.online restores that snapshot for Lua to read, but replayed output does not run browser automation.

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 while accepting any valid package sent by the server.