GMCP Specification
The following outlines the GMCP specification for gLPU, including what is sent by the server and what is sent by the client, as well as expectations and any default behaviour.
Info
Oubound Messages
-
All numeric values are ultimately sent as strings, i.e.
10
is sent as"10"
and1.5
is sent as"1.5"
. -
gLPU, as a FluffOS MUD, does not support boolean values and therefore all boolean values are sent as
"true"
or"false"
strings. -
gLPU, as a FluffOS MUD, does not support the concept of
null
,nil
, orundefined
and therefore all such values are sent as0
. -
Although the examples provided below may be shown on multiple lines, they sent as a single line JSON string.
Inbound Messages
-
Boolean values sent as native
true
orfalse
values are received just fine and are automatically converted to the corresponding LPC values of1
and0
respectively. -
Null values sent as native
null
values are received just fine and are automatically converted to the corresponding LPC value of0
. -
Although the examples provided below may be shown on multiple lines, they are expected to have been sent as a single line JSON string.
Note
Examples may include the same hash for multiple objects to simplify the demonstration. In practice, each object will have a different hash id.
Supported Packages and modules
Core
Client
Core.Hello
Identifies the client to the server. Client and version are sent as JSON object. This should be the first message sent by the client to the server.
Core.Ping
Sent by the client to the server to send a Core.Ping
in response. A payload
is optional, and if present is an integer representing the average ping
time from previous requests.
gLPU by default does not make use of the information provided in this message's payload.
Core.Supports
This module is used to inform the server of the client's supported features.
Core.Supports.Set
Send the client's supported features to the server, all at once in one message.
The format a JSON array of strings and integers where the strings are the GMCP packages and the integers are the module versions.
Per the GMCP specification, Core.Supports.Set
will always overwrite
any existing information, whether from previous .Set
, .Add
, or
.Remove
messages.
gLPU does not make use of the module version information supplied by the client.
Core.Supports.Add
Ordinarily, all information from a client is sent at once via Core.Supports.Set
,
however, sometimes there are plugins or extensions to a MUD client that add
additional capabilities. In such cases, Core.Supports.Add
can be used to
announce those capabilities to the server. They are sent one at a time in a
similar format to Core.Supports.Set
with the name of the package and the
version number.
Core.Supports.Remove
Remove any module from being supported. This informs gLPU that the client would no longer like to receive information for that module.
The format is a JSON array with the name(s) of the module(s) to remove. No version number is required.
Server
Core.Ping
Sent by the server to the client to respond to a Core.Ping
. There is no
payload.
Core.Goodbye
Sent by the server to the client to inform that the character has been logged out. The payload is a string which can contain any message, including a reason for the disconnection.
Char
Client
Char.Login
This module handles the login process for a character.
Char.Login.Credentials
Sent by the client to the server to login a character. The payload is a JSON object with the following keys:
account
- The account namepassword
- The password
Char.Items
Sent by the client to request inventory information.
Char.Items.Contents
Request a list of all items within a specified container. The payload is a string reflecting the hash of the container to list items from. The container must be located in the room the character is in, or in the character's inventory.
Char.Items.Inv
Request a list of all items in the character's inventory. There is no payload.
Char.Items.Room
List items in the room the character is in. There is no payload.
Server
Char.Login
Processes the login request from the client and send back the result.
Char.Login.Result
Sent by the server to the client to inform the result of the login attempt. The payload is a JSON object with the following keys:
success
- A string representing a boolean indicating if the login was successful: "true" or "false"message
- A string containing a message to the client
Char.Items
Char.Items.List
List items in a specific inventory or container. The payload is a JSON object as a string with the following keys:
-
location
- The location of the container to list items from. Possible values are:"inv"
- The character's inventory,"room"
- The room the character is in,"hash"
- The object ID of a container in the room or the character's inventoryitems
- A JSON array of objects representing the items in the container. Possible keys for each item are:"hash"
- The object ID of the item"name"
- The name of the item"icon"
- The icon of the item"id"
- The IDs of the item"attributes"
- This is an undelimited string containing the attributes of the item. Possible attributes are:w
- wornW
- wearable, but not wornl
- wieldedc
- containert
- takeablem
- monsterd
- dead monster
Example
Char.Items.List {
"location": "8351cdf67f1b439de383d0bda83318e2",
"items": [
{
"hash": "8351cdf67f1b439de383d0bda83318e2",
"name": "potion of healing",
"icon": "potion",
"id": [ "potion", "potion of healing" ],
"attributes": "t"
},
{
"hash": "8351cdf67f1b439de383d0bda83318e2",
"name": "loaf of bread",
"icon": "food",
"id": [ "bread", "loaf of bread" ],
"attributes": "t"
}
]
}
Char.Items.Add
Add an item to either the character's inventory or the room the character is in.
The payload is a JSON object in the same format as Char.Items.List
, except
that it is only one item, and therefore the key will be item
.
Example
Char.Items.Remove
Remove an item from either the character's inventory or the room the character
is in. The payload is a JSON object in the same format as Char.Items.Add
.
Example
Char.Items.Update
Update an item in either the character's inventory or the room the character
is in. The payload is a JSON object in the same format as Char.Items.Add
.
Example
Char.Vitals
Sent by the server to the client to provide the character's vital statistics. The payload is a JSON object with the following keys:
hp
- The character's health pointsmax_hp
- The character's maximum health pointshp_ratio
- The character's health points as a ratio of maximum health pointssp
- The character's skill pointsmax_sp
- The character's maximum skill pointssp_ratio
- The character's skill points as a ratio of maximum skill pointsmp
- The character's movement pointsmax_mp
- The character's maximum movement pointsmp_ratio
- The character's movement points as a ratio of maximum movement points
Any and all values may be present in the payload, depending on what information has changed.
Example
Char.Status
Sent by the server to the client to provide the character's status information. The payload is a JSON object with the following keys:
name
- The character's namexp
- The character's experience pointstnl
- The character's time until next levellevel
- The character's levelfill
- The character's fill levelcapacity
- The character's capacitycurrent_enemy
- The character's current enemycurrent_enemy_health
- The character's current enemy's healthcurrent_enemies
- The character's current enemiesseen_enemies
- The character's seen enemieswealth
- The character's wealth
Any and all values may be present in the payload, depending on what information has changed.
Example
Char.Status {
"name": "Aragorn",
"xp": "100.0", "tnl": "200.0", "level": "10",
"fill": "15.0", "capacity": "100.0",
"current_enemy": "Goblin", "current_enemy_health": "100.0",
"current_enemies": [ "Goblin", "Orc" ],
"seen_enemies": [ "Goblin", "Orc", "Troll" ],
"wealth": {
"copper": "10",
"silver": "10",
"gold": "10",
"platinum": "10"
}
}
Char.StatusVars
Sent by the server to the client to provide the character's status variables.
These correspond to the variables listed in the Char.Status
payload and are
provided once, upon initial connection, as a way for the client to get the
key/value pair of label/friendly name of the status variables, perhaps for use
in a GUI.
The payload is a JSON object of key/value pairs where the key is the label of the status variable and the value is the friendly name of the status variable.
Example
Room
Server
Room.Info
Sent by the server to the client to provide the room's information. The payload is a JSON object with the following keys:
hash
- The hash of the roomarea
- The name of the areacoords
- The coordinates of the room, as an array of 3 numbers representing x, y, and z respectivelyenvironment
- The environment of the roomexits
- An object containing key/value pairs of exit direction and hash of the room to which the exit leads.icon
- The icon of the roomsize
- The size of the room, as an array of 3 numbers representing width, height, and depth respectivelytype
- The type of the roomsubtype
- The subtype of the room
Example
Room.Info {
"area": "Olum",
"coords": { "-1", "0", "0" },
"environment": "road",
"exits": {
"east": "ce53e6d9d4757b0d7c04223755216865",
"south": "7ce32c91980d5d8cfbd25a6b36cc134c",
"west": "d91efff11de437aed3974b4428a320e0"
},
"hash": "61660eac2b962b70ab782ee6f697c592",
"icon": "",
"name": "A Path Through the Village",
"size": { "1", "1", "1" },
"subtype": "",
"type": "room"
}
Room.Travel
Sent by the server in response to the travel
command. The payload is an array
of strings representing the hashes of the rooms to be traveled to.
This can be used by the client to initiate a speedwalk to the target room. If the character is to be traveling to more than one location, the client should ensure that a pause is introduced betweeen each destination of at least 2 seconds.