Chapter 11. Timers

Timers allow you to execute commands repeatedly at fixed intervals, and also to specify a command to be executed later.

Timers have to mandatory attributes: an interval in seconds, that represents how often the timer is fired, and an action, that is the command that is executed. Just like in other places, the action can be a text that is sent to the MUD, or it can be something run with Perl.

It is possible to define timers that execute only a fixed number of times. This is the timer's repeat count. Whenever the timer is executed, this count is decreased, and when it reaches zero, the timer is disabled, and will only execute again if reenabled manually. A timer can also be temporary: in this case, when the repeat count reaches zero, it is deleted and not only disabled. A repeat count of -1 means that the timer is executed indefinitely.

A timer with a repeat count of one is executed only once. Since the first execution only happens interval seconds after it is defined, this allows you to define a command to be executed after some specified time. If it is marked as temporary, the timer will be deleted after it is run this one time.

11.1. Creating and Editing Timers

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

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

Figure 11-1. The graphical Timer editor

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

11.1.1. Adding Timers

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

Figure 11-2. The window to edit timers

What can be set represents the columns described above.

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

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

11.1.2. Altering Timers

To edit a timer, 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 timer (see Section 11.1.1) will be opened, filled with the timer'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 timer will remain as it was before.

Another shorter way to edit a timer 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 timer list. Make sure that the timer you want to change is selected, and click in the check button. The state will be toggled.

To delete a timer, 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 timer. 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 timer again. See Section 4.7. To delete several timers at once, select them all and press Delete.

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