|
|
|
An Event is similar to a trigger, but instead of firing when text from the MUD is received, it is fired internally by CMUD when a certain situation occurs. For example, the "onConnect" event is fired when CMUD connects to the MUD.
There are several Pre-defined Events within CMUD. You can also create your own user-defined events.
Simply use the #EVENT command to create your own event handler, and then use #RAISE to fire the event.
For example, you might want to detect when the MUD prompt is received from the MUD:
#TRIGGER {(%d)hp (%d)mana >} {#RAISE onPrompt %1 %2} "" {prompt}
This will cause all "onPrompt" event handlers to fire, in any package, when the MUD prompt is received. Arguments are passed to the event handler, just like with aliases. In fact, the #EVENT command can use named-arguments, just like an alias. For example:
#EVENT onPrompt($hp,$mana) {#IF ($hp < 50) {cast heal}}
This event handler checks the first argument (the hp from the prompt) and heals the character if the hp value is too low. You can create as many event handlers for each event as you want. You can even put these event handlers in different packages. |
|