Manual:Supported Protocols

From Mudlet
Jump to navigation Jump to search

Supported Protocols

Mudlet supports GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol. MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP can be enabled in settings.

Game protocols toggle.png

GMCP

Generic Mud Communication Protocol, or GMCP, is a protocol for MUD servers to communicate information with MUD clients in a separate channel from the one which carries all of the text that makes up the game itself. Enabling the Debug window will show you GMCP events as they are coming in, and to get an idea of what information is currently stored, hit the Statistics button.

When working with GMCP on IRE games, this GMCP reference is a useful tool.

Using GMCP

Receiving GMCP data

To "trigger" on GMCP messages, you'll need to create an event handler - Mudlet will call it for you whenever relevant GMCP data is received.

As an example, create a new script and give it a name of the function you'd like to be called when the relevant GMCP message is received. Then, add the GMCP event you'd like the function to fire on under the registered event handlers left. Lastly, define the function - either in this or any other script - and you'll be done. The GMCP data received will be stored in the corresponding field of the gmcp table, which your function will read from.

Example:

Using gmcp.png

The test_gmcp() function will be called whenever Char.Vitals is received from the game, and it'll echo the latest data on the screen.

Sending GMCP data

Certain modules will only send data when a request is made by your client. In Mudlet, you can make such a request using the command sendGMCP("command"). Read your MUD's relevant documentation, such as the IRE document on GMCP, for information about specific modules.

See Also: sendGMCP

Managing GMCP modules

While some GMCP modules are enabled by Mudlet by default when you connect with a GMCP enabled MUD, others may not be 'standard' modules and are instead specific to the MUD itself. In order to provide a way to manage GMCP modules without scripts causing modules in use by other scripts to be disabled. Note Note: The gmod lua module has been included with Mudlet (rc2.0+).

Registering user

While this step is no longer strictly required, you can register your 'user' with gmod using

gmod.registerUser("MyUser")

Where MyUser is your plugin/addon/whatever name. However, your user will be automatically registered if you enable or disable any modules using it. Which leads us to...

Enabling modules

Enabling a GMCP module is as easy as:

gmod.enableModule("MyUser", "Module.Name")

If MyUser has not been registered previously, then they will be automatically registered when you call this function. An example of a module which would need to be enabled this way is the IRE.Rift module provided by IRE MUDs.

-- add this to a login trigger, or anything that will get done just once per login
gmod.enableModule("<character name>", "IRE.Rift")

Another example would be the Combat module in Lithmeria, which isn't enabled by default:

-- add this to a login trigger, or anything that will get done just once per login
gmod.enableModule("<character name>", "Combat")

Disabling modules

Disabling a GMCP module is just as easy as enabling it:

gmod.disableModule("MyUser", "Module.Name")

The main difference being that the module will be turned on as soon as you enable it if it is not already enabled. If you disable it, it will not be disabled with the server until every user of that module has disabled it. This prevents script A from disabling modules that script B may still be using.

Thorough GMCP tutorial

A good GMCP tutorial that walks you through receiving and sending GMCP data is available here - take a read!

MSDP

MSDP is a protocol for MUD servers to communicate information with MUD clients in a separate channel from the one which carries all of the text that makes up the game itself. Mudlet can be configured to use MSDP by clicking on the Settings button (or Options->Preferences in the menu, or <alt>p). The option is on the General tab.

Once MSDP is enabled, you will need to reconnect to the MUD so that Mudlet can inform the server it is ready to receive GMCP information. Please note that some servers don't both send MSDP and GMCP at the same time, so even if you enable both in Mudlet, the server will choose to send only one of them.

Enabling the Debug window will show you MSDP events as they are coming in, and to get an idea of what information is currently stored, hit the Statistics button. Also see MSDP reference for some of the commands and values your server might support.

Using MSDP

Receiving MSDP data

To "trigger" on MSDP messages, you'll need to create an event handler - Mudlet will call it for you whenever relevant MSDP data is received.

As an example, lets create a script that'll track whenever we move - that is, the room number changes. To begin with, we need to ask the game to be sending us updates whenever we move - so do:

lua sendMSDP("REPORT", "ROOM_VNUM")

in the command-line first to enable reporting of the room number and name. Then, create a new script and give it a name of the function you'd like to be called when the relevant MSDP message is received. Add the MSDP event you'd like the function to fire on under the registered event handlers - in our case, msdp.ROOM_VNUM. Lastly, define the function - either in this or any other script - and you'll be done. The MSDP data received will be stored in the corresponding field of the msdp table, which your function will read from.

Example:

Using msdp.png

The test_msdp() function will be called whenever ROOM_VNUM is received from the game, and it'll echo the latest data on the screen.

Sending MSDP data

You can use sendMSDP to send information via MSDP back to the game. The first parameter to the function is the MSDP variable, and all the subsequent ones are values. See the MSDP documentation for some examples of data that you can send:

-- ask the server to report your health changes to you. Result will be stored in msdp.HEALTH in Mudlet
sendMSDP("REPORT", "HEALTH")

-- client - IAC SB MSDP MSDP_VAR "SEND" MSDP_VAL "AREA NAME" MSDP_VAL "ROOM NAME" IAC SE in the documentation translates to the following in Mudlet:
sendMSDP("SEND", "AREA NAME", "ROOM NAME")
See Also: sendMSDP

MSSP

Mud Server Status Protocol, or MSSP, provides a way for MUD crawlers (i.e. MSSP Mud Crawler) and MUD listing sites (search for Listings here) to gather detailed information about a game, including dynamic information like boot time and the current amount of online players. It also makes submitting a new game entry very simple on MUD listing sites. A player or administrator is only required to fill in the hostname and port and other information is gathered from behind the scenes.

MSSP in Mudlet

The MSSP data presented in Mudlet will enable MSSP standard data fields to be made accessible for scripting. Some useful fields include the game name, number of players, uptime, game hostname, game port, codebase, admin contact, Discord invite URL, year created, link to an icon, ip address, primary language, game location, website and several others may be available. It is up to the game in question to populate the data, so don't expect all fields to be filled in.

MSSP is available in Mudlet 4.1+.

Receiving MSSP Data

To receive MSSP data in Mudlet, these conditions must be met:

  1. The Enable MSSP box in the Settings window of Mudlet must be checked.
  2. The game must negotiate MSSP with clients like Mudlet at its login screen. Details here.

To see whether your game supports MSSP, after connecting, type lua mssp. If the game does not support MSSP, you will see an empty table mssp = {}. If it does you will see information similar to the example below. The data may be accessed in a similar way to the instructions for GMCP listed above. Typically, MSSP data is only sent once per connection.

mssp = {
  HOSTNAME = "stickmud.com",
  VT100 = "1",
  UPTIME = "1565657220",
  MSDP = "0",
  MCP = "0",
  GMCP = "1",
  PORT = "7680",
  ["MINIMUM AGE"] = "13",
  PUEBLO = "0",
  INTERMUD = "-1",
  SKILLS = "100",
  ["HIRING BUILDERS"] = "0",
  PLAYERS = "6",
  CONTACT = "askstickmud@hotmail.com",
  CODEBASE = "LDMud 3.5.0 (3.5.1)",
  ["HIRING CODERS"] = "0",
  ["PAY FOR PERKS"] = "0",
  LOCATION = "Canada",
  GAMESYSTEM = "Custom",
  MCCP = "0",
  SUBGENRE = "Medieval Fantasy",
  ROOMS = "10000",
  STATUS = "Live",
  FAMILY = "LPMud",
  LEVELS = "150",
  CREATED = "1991",
  ["PAY TO PLAY"] = "0",
  IP = "24.138.28.11",
  MOBILES = "-1",
  GAMEPLAY = "Hack and Slash",
  CLASSES = "8",
  NAME = "StickMUD",
  SSL = "0",
  ANSI = "1",
  ICON = "https://www.stickmud.com/favicon.ico",
  RACES = "12",
  UTF-8 = "0",
  AREAS = "-1",
  MXP = "0",
  HELPFILES = "-1",
  ["XTERM 256 COLORS"] = "0",
  MSP = "1",
  OBJECTS = "9780",
  WEBSITE = "https://www.stickmud.com",
  GENRE = "Fantasy",
  DISCORD = "https://discord.gg/erBBxt",
  LANGUAGE = "English"
}

MSP

Want to add accessibility and excitement into your game? How about implementing sound and music triggers?

Mud Sound Protocol, or MSP, provides a way for games to send sound and music triggers to clients. Clients have the option to implement a framework where the corresponding triggers play. MSP triggers are sent in one direction to game clients and not to game servers. Sounds may be downloaded manually or automatically if conditions are met.

Games could use telnet option negotiation to signal clients support for MSP (WILL, WONT), and toggling MSP processing on and off (DO, DONT). This is communicated using TELOPT 90, which is reserved (unofficially) for the MSP protocol by our community. Games that do not support telnet option negotiation for MSP should provide a means for their players to toggle this feature on and off.

The latest specification for MSP is located here.

MSP in Mudlet

Mudlet processes MSP sound and music triggers in three ways:

  1. MSP for Lua - Mudlet triggers may capture and invoke the receiveMSP function available through the Lua interpreter of Mudlet to process MSP.
  2. MSP over GMCP - Mudlet supports Client.Sound and Client.Music GMCP packages that enable games to trigger MSP processing.
  3. MSP over OOB - Mudlet is capable of receiving hidden, out-of-band telnet sound and music triggers from game servers via messaging with TELOPT 90.

Sound or music triggers that contain a media file name will be searched for in the media folder of the corresponding Mudlet profile that matches the host for the game. If the media folder and the file are found by Mudlet, it will be played, given the host's operating system supports playing that type of media file. If the file is not found, Mudlet could initiate a download of the media file when provided a URL to find the file. Alternatively, game administrators may instruct players on other ways to transfer media files by 1) creating a media folder in their game's Mudlet profile and 2) copying files or extracting them from an archive (zip).

MSP is available in Mudlet 4.4+

Receiving MSP Data

Processing of MSP is enabled by default on new game profiles. Control whether the processing is on or off through the Settings menu in Mudlet.

MSP for Lua

Check for MSP support with your game and enable any options that allow sound and music triggers to be sent to your screen.

Create a sound trigger to invoke the Lua interpreter:

  • Name: Sound Trigger
  • Text: ^!!SOUND\((\S+?)(?: (.+))?\)$
  • Type: perl regex
  • Script: deleteLine() receiveMSP(matches[1])

Create a music trigger to invoke the Lua interpreter:

  • Name: Music Trigger
  • Text: ^!!MUSIC\((\S+?)(?: (.+))?\)$
  • Type: perl regex
  • Script: deleteLine() receiveMSP(matches[1])

MSP over GMCP

Processing of GMCP is enabled by default on new game profiles. Control whether the processing is on or off through the Settings menu in Mudlet. Although you may receive Client.Sound and Client.Music GMCP, MSP will not process if MSP is disabled in the Settings menu.

The following is a guide to the GMCP syntax for Client.Sound and Client.Music:

Client.Sound

  • This will often be sent upon connection by game servers to inform the client of where to download files when a URL is not specified in the Client.Sound triggers that follow.
Client.Sound { "url": "https://www.example.com/sounds/" }
  • All Client.Sound GMCP requires a name key which contains the media file to be played or the reserved word Off to turn off all sound triggers. Wildcards ? and * may be used to return any matching files. If more than one match is returned, a random file will be picked. If a filename has no extension (i.e. .wav or .mp3) then per the specification a .wav will be automatically appended to the file name for sound triggers.
Client.Sound { "name": "filename.wav" }
Client.Sound { "name": "f?lena*" }
Client.Sound { "name": "Off" }
  • The volume parameter controls volume.
  • The length defaults to playing the sound 1 time, while more iterations could be specified as integers greater than 1. If length is -1 the sound will loop indefinitely until a sound trigger with a name of Off is sent or a sound with a higher priority is received. Using the length parameter with greater than 1 iteration combined with wildcards provide some creative effects!
  • The priority parameter helps calculate whether Mudlet will stop an already playing sound and play the current sound instead. For instance, if a player is in combat, you may want to raise combat sounds to a priority level of 100, which will be more than the default of 50. If two sounds have the same priority, the sound that is already playing wins out.
  • The type parameter will be used to group sounds with the same type specified into the same folder, which could be very handy when combined with file wildcards. The value of the type parameter is case insensitive, so all folders matching types will be stored as lower case under the media folder in the profile.
  • The url parameter will update the URL for where the client will download sounds.
Client.Sound {
  "name": "<required: filename | Off>",
  "volume": "[optional: 1-100 | 50 = Default]",
  "length": "[optional: -1 = Repeats | 1 = Default | 1 or more iterations]",
  "priority": "[optional: 1-100 | 50 = Default]",
  "type": "[optional: folder]",
  "url": "[optional: a URL]"
}

Client.Music

  • This will often be sent upon connection by game servers to inform the client of where to download files when a URL is not specified in the Client.Music triggers that follow. If this was already done for sounds, it will be the same value for music, so it is likely you won't see this much.
Client.Music { "url": "https://www.example.com/sounds/" }
  • All Client.Music GMCP requires a name key which contains the media file to be played or the reserved word Off to turn off all music triggers. Wildcards ? and * may be used to return any matching files. If more than one match is returned, a random file will be picked. If a filename has no extension (i.e. .mid or .mp3) then per the specification a .mid will be automatically appended to the file name for music triggers.
Client.Music { "name": "filename.mp3" }
Client.Music { "name": "f?lena*" }
Client.Music { "name": "Off" }
  • The volume, length. priority and type parameters for Client.Music are identical to the guidance mentioned above for Client.Sound.
  • The continue parameter is helpful to guide whether identical music that is already playing should continue playing if requested again. A value of 1 is the Default, and will allow already playing music to continue, which could be very helpful for instance if all of the same music is played for an entire area inside of a game. If a value of 0 is specified, a music file that was a match for music already playing will restart from the beginning.
Client.Music {
  "name": "<required: filename | Off>",
  "volume": "[optional: 1-100 | 50 = Default]",
  "length": "[optional: -1 = Repeats | 1 = Default | 1 or more iterations]",
  "priority": "[optional: 1-100 | 50 = Default]",
  "continue": "[optional: 0 = Restart if already playing | 1 = Default, Continue if already playing]",
  "type": "[optional: folder]",
  "url": "[optional]"
}

The following are some examples of GMCP and the type of processing Mudlet would perform. Please note that number values could be strings or integers.

Client.Sound

  • Sets the URL where media files will be downloaded
Client.Sound { "url": "https://www.example.com/sounds/" }
  • Plays cow.wav, max volume, one time
Client.Sound { "name": "cow.wav", "volume": "100", "length": "1" }
  • Plays wow.wav, high volume, one time, .wav added for sound when not specified
Client.Sound { "name": "wow", "volume": "75", "length": "1" }
  • Plays cow.wav and wow.wav, default volume, five times randomly
Client.Sound { "name": "?ow.wav", "volume": "50", "length": "5" }
  • Plays cow.wav, low volume, repeat indefinitely from animals subdirectory under media
Client.Sound { "name": "co*", "volume": "25", "length": "-1", "type": "animals" }
  • Plays stab.wav, max volume, max priority, from the combat subdirectory under media
Client.Sound { "name": "stab.wav", "volume": "100", "priority": "100", "type": "combat" }
  • Turn off all sound for this profile, "Off" is a reserved keyword
Client.Sound { "name": "Off" }

Client.Music

  • Sets the URL where media files will be downloaded
Client.Music { "url": "https://www.example.com/sounds/" }
  • Plays rain.mid, default volume, two times, continue if already playing
Client.Music { "name": "rain", "volume": "50", "length": "2", "continue": "1" }
  • Plays city.wav, low volume, one time, restart if already playing
Client.Music { "name": "city.wav", "volume": "25", "length": "1", "continue": "0" }
  • Turns off all music for this profile, "Off" is a reserved keyword
Client.Music { "name": "Off" }

MSP over OOB

Game administrators may send sound and music triggers over the out-of-bounds (hidden) telnet channel encoded with TELOPT 90 after performing telnet negotiation with Mudlet. The advantages to this are similar to MSP over GMCP in that all of the communication is behind the scenes with no additional setup requirements for the player (i.e. MSP over Lua). Games will send the bytes of out-of-band messages to Mudlet in a format like this:

IAC SB TELOPT_MSP !!SOUND(cow.wav L=2 V=100) IAC SE

MSP Troubleshooting

  • Wildcards ? or * within the file name do not trigger automatic sound or music downloads. Ensure the sound was downloaded previously prior to using a wildcard.

MSP Specification

For more insight into the syntax of sound and music triggers, please reference the specification.

ATCP

Since version 1.0.6, Mudlet includes support for ATCP. This is primarily available on IRE-based MUDs, but Mudlet's implementation is generic enough such that any it should work on others.

The latest ATCP data is stored in the atcp table. Whenever new data arrives, the previous is overwritten. An event is also raised for each ATCP message that arrives. To find out the available messages available in the atcp table and the event names, you can use display(atcp).

Note that while the typical message comes in the format of Module.Submodule, ie Char.Vitals or Room.Exits, in Mudlet the dot is removed - so it becomes CharVitals and RoomExits.

Example
room_number = tonumber(atcp.RoomNum)
echo(room_number)

Triggering on ATCP events

If you’d like to trigger on ATCP messages, then you need to create scripts to attach handlers to the ATCP messages. The ATCP handler names follow the same format as the atcp table - RoomNum, RoomExits, CharVitals and so on.

While the concept of handlers for events is to be explained elsewhere in the manual, the quick rundown is this - place the event name you’d like your script to listen to into the Add User Defined Event Handler: field and press the + button to register it. Next, because scripts in Mudlet can have multiple functions, you need to tell Mudlet which function should it call for you when your handler receives a message. You do that by setting the Script name: to the function name in the script you’d like to be called.

For example, if you’d like to listen to the RoomExits event and have it call the process_exits() function - register RoomExits as the event handler, make the script name be process_exits, and use this in the script:

function process_exits(event, args)
    echo("Called event: " .. event .. "\nWith args: " .. args)
end

Feel free to experiment with this to achieve the desired results. A ATCP demo package is also available on the forums for using event handlers and parsing its messages into Lua datastructures.

Mudlet-specific ATCP

See ATCP Extensions for ATCP extensions that have been added to Mudlet.

Aardwolf’s 102 subchannel

Similar to ATCP, Aardwolf includes a hidden channel of information that you can access in Mudlet since 1.1.1. Mudlet deals with it in the same way as with ATCP, so for full usage instructions see the ATCP section. All data is stored in the channel102 table, such that you can do:

display(channel102)

... to see all the latest information that has been received. The event to create handlers on is titled channel102Message, and you can use the sendTelnetChannel102(msg) function to send text via the 102 channel back to Aardwolf.

-- Function for detecting AFK status on Aardwolf mud.
function amIafk()
   for k,v in pairs(channel102) do
      if k==100 and v==4 then
         return true
      end
   end
   return false
end

MXP

MXP is based loosely on the HTML and XML standards supported by modern web browsers. It is only "loosely" based upon these standards because MUDs require dynamic, streaming text, rather than the page-oriented view of web browsers. Also, the existing standards are needlessly verbose for use on a MUD where text efficiency is important.

In addition, there are additional security concerns to worry about with MXP. While support for HTML tags within a line is desired, players on a MUD can exploit this power and cause problems. Certain HTML functions need to be restricted so that MUD players cannot abuse them. For example, while it might be desirable to allow players to change the font or color of their chat messages, you would not want to allow them to display a large graphics image, or execute script commands on the client of other users. MXP handles this by grouping the various tags and commands into secure and open categories, and preventing the secure tags from being used by MUD players.

Mudlet implements a subset of MXP features - the most popular ones that are actually in use. Mudlet supports MXP links (including send to prompt and open in browser (Mudlet 3.17+)), pop-up menus, creation of custom elements, and line modes.

Secure connection (TLS)

To connect to a game securely, tick the 'Secure' box in the profile connection settings:

Secure-connection.png

Note that the game must support a secure (TLS) connection in order for this to work, and this feature is available in Mudlet 3.17+.

If you are a games admin/developer, check out this or this example on how to setup a secure connection to your game.

Adding support for a telnet protocol

In addition to supporting ATCP, GMCP, Aardwolf's 102 and MXP, Mudlet has open telnet support - meaning that for any telnet protocol it doesn't support, it has the tools you can use to build the support for. This does not mean Mudlet supports other protocols "out of the box" - you will either have to get code that adds the support, or you could create it yourself.

The basic tools that you need are addSupportedTelnetOption(), sendSocket() and the sysTelnetEvent.

Create an event handler that goes off on sysTelnetEvent - which is raised whenever an unsupported telnet option is encountered. Your logic handling will start in this event handler. Once you decide what you'd like to send to the MUD, use sendSocket() to send raw data as-is. Finally, when your logic is done, use addSupportedTelnetOption() to register your telnet option with Mudlet, so it will respond with telnet DO on a query from the MUD server. See this MSDP snippet for a barebones example.

API philosophy

Adding a support for a new telnet protocol will involve adding the user-facing API. It best for users if it was in the same style as Mudlets handling of other protocols. To see how it's done exactly, check out GMCP, ATCP or Aardwolf 102 examples - but the gist of it is provided below.

Mudlet has a built-in event system, which is used to broadcast messages in an independent way. With it, people can "trigger" on 102, ATCP or GMCP events with Lua functions that get called whenever an event they're interested in is raised. Use the event system to provide your users with a way to react to new protocol data.

Events have names, and optionally, any amount of data with them. For protocol support, Mudlet prefixes the relevant message received name with the protocol name in lowercase. For example, an ATCP Char.Vitals getting updated would raise an event titled "atcp.Char.Vitals". A GMCP Room.Info message would raise a "gmcp.Room.Info" message.

Additionally, Mudlet also allows catch-all event - in case the user wants to use one event handler for a variety of sub-events (it's not uncommon for MUDs to use Main.Sub.Add, Main.Sub.Remove, Main.Sub.List to keep track of a list, for example, while conserving data). To accomplish this, it raises events for every relevant namespace - that is, a Main.Sub.Add event will raise protocol.Main.Sub and protocol.Main.Sub.Add events. While it is entirely possible for one event handler to react to multiple events, this is provided for convenience.

For storing protocol data, Mudlet uses an aptly named global table - gmcp for GMCP data, atcp for ATCP data. Data is stored in the same way it is received and the event is raised for - so a Char.Vitals message's contents will be stored in gmcp.Char.Vitals, a Room.Info's contents in gmcp.Room.Info. If there were was any nested data within the message, it is stored as a table within the proper namespace - ie, a "details" JSON array of a GMCP Room.Info message would be stored in gmcp.Room.Info.details. Use a global table with the protocol name in lowerspace for storing permanent data that your users will read from.

That's it! If you'll need any Mudlet-related help, feel free to post on our forums. Once you're done, package your work for distribution which you can optionally post in the finished scripts section.