...
- 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"
- 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
CMUD Specific
To use GMCP in CMUD, you use Triggers,
- Make a new trigger
- Set its pattern to the gmcp module name you are interested in, e.g. "Char.Vitals" (This means the trigger will automatically fire when the mud sends updated vitals)
- Change the Trigger type to "GMCP"
- In the script part, you can now access the variables directly using %gmcp.Char.Vitals.hp, e.g.
- #VAR hp %gmcp.Char.Vitals.hp
- or
- hp = %gmcp.Char.Vitals.hp