GMCP is handlet a little bit differently in different clients. E.g. in CMUD it is considered an event, and is handled with event handlers. While in CMUD it is considered a special form of trigger. Also access to the properties are not always the same.
Both clients will "cache" previous values, so this is important when it comes to gmcp objects where the contents/properties change pr fire.
Below i will try to create examples for common use cases in Mudlet and CMUD.
You can use the "display" command to output the full, or parts of the gmcp tree, or print/echo to print out a single property.
Examples:
In Mudlet, a gmcp packet is considered an event. The events are named with dotted syntax. e.g. gmcp.Room or gmcp.Char.Vitals
Note that capitilization is important.
A "sub handler" will only fire on the specific event, while a "super" will fire on all sub events. E.g.
There are two main ways to setup handlers for events in Mudlet. I recommend reading the documentation for the Mudlet Event_Engine for details, but i will brifely describe the methods here:
handlerId = registerAnonymousEventHandler("gmcp.Char.Vitals", "processCharVitals")
Note! make sure to save the handlerid, and check for its existance before you register a handler when usign this method, otherwize you might get multiple fires pr event
Note! I do not recomment method 2 unless you are very experienced with Lua and event programming. This is because it is VERY easy to get into a state where the handler will fire multiple times. |
To use GMCP in CMUD, you use Triggers,