Macros

A macro is a simple named definition of a set of commands. When the macro is used its body of commands will be sent to the server. Macros cannot be recursive, which means that they cannot call upon itself, but they can call upon other macros. You should therefore be aware of that you can create infinite loops that will lockup your client if you make one macro that calls another macro which in turn calls the first macro again. Do NOT do this unless you want to create a deadlock and crash the client software!

The body of a macro can contain several commands that are split up with the ";" character. For example the macro body "smile;grin;north" will issue three different commands to the game server.

The following commands can be used to manage macros:
/macro name = body
/macrolist
/unmacro name

To run a macro from the commandline or from within a trigger you use the "/"+ the macro name. For example "/testmacro". Certain names are restricted and cannot be used for macros such as all the "/" commands for manipulating certain things in the client such as scripts, macros and triggers.

Macros are saved between session to the file: user.dir/batclient/conf/macros.xml.

Note that macros cannot contain any "scripting" code in their body. Only one lined simple "commands". To make "if statements" and similar you will have to write scripts that the macro will call.

The body of a macro can contain %1 %2 ... %n to refer to any regexp pattern matches that has occurred in a trigger OR to any arguments given to the macro body. For example if you call a macro with "/test a b c" %1 will be "a", %2 will be "b" and %3 will be "c". %0 points to the entire argument string "a b c".

If you instead have a trigger with regexp pattern that looks something like "(\\w*) say '(.*)'" and a trigger body that is "/test". The /test macro could be defined to be "/macro test = say %1 %2". When the trigger is matched to a string like "You say 'test'" the macro "/test" will be executed as: "say You test". The %1 .. %n variables are automatically forwarded to the macro body from a trigger.

Some example macros:

  • /macro test = say This is a test macro!
    This will simply send "say This is a test macro!" to the server.
  • /macro test = $doTest.doSomething
    This macro will call upong the doTest script and the doSomething method inside the script.