Chapter 8. Triggers

Triggers allow you to react automatically to text that comes from the MUD. This reaction can be of two forms: sending something to the MUD in reply, or there may be no direct interaction with the MUD, but something might be printed in the screen, or something else done to call your attention.

Sometimes the action of a trigger is to change the line that was received and that activated the trigger. You might want to match all lines that contain a certain word (such as your character's name) and print these lines (or part of these lines) in a different color to draw attention. And sometimes you might want to omit some lines, such as everything said by some annoying player, or some messages that are not relevant for you. This kind of trigger is often called a gag. Both these features are supported by KildClient.

Triggers are defined by specifying a pattern against which all lines received from the MUD are matched. If there is indeed a match, an action specified by you is executed. If the trigger is a gag, then the line that matched will not be printed in the screen, otherwise it is printed normally. (Note that printing actually happens before the action is executed, even if here things were described in another order for ease of understanding.)

The above description was very brief and was meant just to give a basic idea of how triggers work. Next follows a more detailed explanation of all aspects involving triggers.

8.1. Creating and Editing Triggers

The easiest way to create and alter triggers is from the World Editor, the place where all settings of a World are altered (see Chapter 4).

Trigger are defined in the Triggers section inside the Automation section. When you open that section, you'll see a list of the defined triggers and some buttons like this:

Figure 8-1. The graphical Trigger editor

The main part of the window is the list of defined triggers. The columns are as follows:

8.1.1. Adding Triggers

To add a new trigger, press the Add button. This will open a window for you to edit the new trigger's parameters:

Figure 8-2. The window to edit triggers

What can be set represents the columns described above.

When you are finished, press OK and the trigger will be added. If you change your mind, press Cancel and the trigger will not be added.

To see some things triggers can do, read Section 8.3. If you want to try the triggers described there, you can create them from the World Editor.

8.1.2. Altering Triggers

To edit a trigger, select it by clicking its line in the list (the line will be highlighted), and press the Edit button. A window like the one used for adding trigger (see Section 8.1.1) will be opened, filled with the trigger's parameters. Change what you want, and press the OK to commit the changes. If, however, you change you mind, press Cancel and the changes will be not be made, the trigger will remain as it was before.

Another shorter way to edit a trigger is to double click its line in the list.

It is also possible to change the value of the binary options (those represented by a check box) directly from the trigger list. Make sure that the trigger you want to change is selected, and click in the check button. The state will be toggled.

To delete a trigger, select it and press the Delete button. You will be asked for confirmation, and can cancel the operation, but once deleted, you cannot recover the trigger. If you want, you can disable this confirmation dialog, but if you do so and click the Delete button, the only way to undo your action will be creating the trigger again. See Section 4.7. To delete several triggers at once, select them all and press Delete.

The final thing that needs to be explained with regard to triggers is how to reorder them. Triggers as tried from the first one to the last, so in a few cases the order might matter. To move a trigger up or down in the list, select it and press the corresponding button.