Chapter 10. Macros

Macros are, in a way, similar to aliases. They allow you to send commands to the MUD in an easier way. Aliases allow you to associate commands with shortcuts (typing a three-letter command to send a much more complex command, for example). Macros allow you to associate a command with a keypress. You could associate, for example, F5 with the command drink from fountain, and then you would only need to press F5 to send that command to the MUD.

The commands need not be complex or big: you could associate the arrow keys with macros that send movement commands, and you would be able to move around the MUD using the arrow keys.

Macros consist of a key and an action. The action represents what is sent to the MUD when the macro is run. It can be a single command to send, several commands separated by %;, or something to be executed by Perl, if it starts with /.

10.1. Creating and Editing Macros

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

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

Figure 10-1. The graphical Macro editor

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

10.1.1. Adding Macros

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

Figure 10-2. The window to edit macros

What can be set represents the columns described above. To define the key, press the key combination desired in the text box for Key and the appropriate key code will be inserted.

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

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

10.1.2. Editing Macros

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

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

It is also possible to change the value of the enabled option directly from the macro list. Make sure that the macro you want to change is selected, and click in the check button. The state will be toggled.

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

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