You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Introduction

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.

Mudlet Specific

How to "look at" the gmcp objects

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:

  • lua display(gmcp.Char)
  • lua print(gmcp.Char.Vitals.hp)

How to react to a gmcp object

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.

  • a handler tied to "gmcp.Char" will fire on gmcp.Char, gmcp.Char.Vitals and gmcp.Char.Effects
  • a handler tied to "gmcp.Char.Vitals" will NOT fire on gmcp.Char.Status or gmcp.Char.Effects

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:

  1. Set up a method as an event handler in the GUI (easiest, but only allows one handler pr script)
    • Create a new script
    • Give it a name, e.g. "onGmcpCharVitals"
    • in the script, create a function with the same name, eg function onGmcpCharVitals()
    • Add the event name to the "Add user Event Handler" (e.g. gmcp.Char.Vitals) and click the "+" button, so that the event name is pushed up to the "Registered Event Handlers"
  2. Use an AnonymousEventHandler (this is somewhat more complex to do right, but allows multiple handlers in the same script), e.g. 
    • 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


Event Handler from the GUIAnonymousEventHandler


CMUD Specific

  • No labels