GMCP Mudlet Tutorial
Enabling GMCP[edit]
In Mudlet you can enable GMCP via the Settings for your session. Once a session is opened, open the Settings:
In the settings, under the Game Protocols
section, ensure the Enable GMCP
checkbox is checked.
Receiving a GMCP message[edit]
Once GMCP is enabled, the MUD will begin broadcasting GMCP messages.
Mudlet automatically saves all data from GMCP messages in a global gmcp
variable.
For example, if you wanted to read the area name from the prompt, you can do this at any time, from anywhere via the following variable:
gmcp.char.prompt.an
Sometimes you need to be able to trigger off of a GMCP message. This can be done by creating a GMCP script.
Create a new script (not a trigger) and give it a name. Enter the package name in the Add User Defined Event Handler
field and hit the "plus" sign to add it. This package name must be prepended by gmcp.
. For example, the char.status
package would be added to the event handlers as gmcp.char.status
. A full list of available packages can be found here.
You can also match partial packages to trigger on multiple GMCP messages.
For example, you can set the pattern to gmcp.char
to trigger on any character related GMCP message.
Sending a GMCP message[edit]
The MUD will not broadcast every message that is available. Some messages must be manually requested. Additionally, some broadcasted messages can also be requested if you need to refresh the data before the MUD would broadcast again.
The following script can be used to send a request to the MUD:
SendGMCP("char.prompt")
If you need to send additional parameters for the requested package, you can do so:
SendGMCP([[char.prompt {"additional": 1, "parameters": "hello"}]])
You can also use the following syntax:
SendGMCP("char.prompt"..yajl.to_string({"additional": 1, "parameters": "hello"})
Note that as of writing, none of the Legend packages take any parameters, required or optional.