Difference between revisions of "GMCP TinTin++ Tutorial"
Line 24: | Line 24: | ||
== Receiving a GMCP message == | == Receiving a GMCP message == | ||
− | Once GMCP is enabled, the MUD will begin broadcasting GMCP messages. To receive these messages, you must subscribe to GMCP events. This must be done for each package you want to receive messages for. | + | Once GMCP is enabled, the MUD will begin broadcasting GMCP messages. To receive these messages, you must subscribe to GMCP events. This must be done for each package you want to receive messages for. A list of available packages can be found [[GMCP Packages|here]]. |
For example, if you wanted to receive the <code>room.info</code> messages, you would use the following script: | For example, if you wanted to receive the <code>room.info</code> messages, you would use the following script: |
Revision as of 07:20, 6 January 2021
Enabling GMCP[edit]
In order to enable GMCP, you need to send a message to the MUD to let it know that the client supports it.
This is done by sending an IAC DO GMCP
message when the MUD sends IAC WILL GMCP
.
In TinTin++, this is done via the following script:
#EVENT {IAC WILL GMCP} { #SEND {\xFF\xFD\xC9}; }
Alternatively, it can be useful to store the hex codes as variables:
#VAR telnet[iac] \xFF; #VAR telnet[do] \xFD; #VAR telnet[sb] \xFA; #VAR telnet[se] \xF0; #VAR telnet[gmcp] \xC9;
#EVENT {IAC WILL GMCP} { #SEND {$gmcp[iac]$telnet[do]$telnet[gmcp]}; }
The other scripts in this tutorial will use those variables. Note that anywhere these variables are used, you can replace them with the hex code instead.
Receiving a GMCP message[edit]
Once GMCP is enabled, the MUD will begin broadcasting GMCP messages. To receive these messages, you must subscribe to GMCP events. This must be done for each package you want to receive messages for. A list of available packages can be found here.
For example, if you wanted to receive the room.info
messages, you would use the following script:
#EVENT {IAC SB GMCP room.info IAC SE} { #VAR roominfo {%0}; }
The %0
parameter contains the data sent by the MUD. For convenience, it is recommended that you save this data in a #VARIABLE
or #LOCAL
.
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:
#SEND {$telnet[iac]$telnet[sb]$telnet[gmcp]<package_name> <message_data>$telnet[iac]$telnet[se]};
It may be easier to create an alias to make this task easier. Aliases can later be used from the input line as well as from other scripts.
#ALIAS {gmcp %1 %*} { #SEND {$telnet[iac]$telnet[sb]$telnet[gmcp]%1 %2$telnet[iac]$telnet[se];}; }
Usage: gmcp room.info {}
The following alias might also be useful if the package does not need any parameters provided:
#ALIAS {gmcp %1} { #SEND {$telnet[iac]$telnet[sb]$telnet[gmcp]%1$telnet[iac]$telnet[se];}; }
Usage: gmcp room.info