|
Macro ManualTable of ContentsGeneral InformationHow Clan Lord Loads Macro FilesWhen you join a game or choose "Reload Macros" from the Options menu, Clan Lord will load the file with the same name as your character from the Macros folder. If no such file exists then it creates a new one. It also creates the macro folder and a file named "Default" if they do not exist. You can tell Clan Lord to load other files located in the Macro folder by having a line like:
This statement loads the other file exactly as if it were inserted where the "include" is. Macro DeclarationsA macro consists of a "trigger" which explains when it should be done, and "commands" which define what it should do. There are two possible ways of declaring a macro, a short form and a long form. If you have more than one command you must use the long form, but with one command you can use either.
Controlling ExecutionWhenever a macro is executing, the text box will display a thicker outline. Typing control-escape will stop all executing macros. More than one macro may be executing at the same time. Some environmental variables can also be set to control how a macro behaves. See the variable section, below.Escape CharactersIn order to use special characters which control how CL loads macros in an expression, you must use a backslash (\) before them. Commonly used ones:
NOTE: When you type a command directly in CL, you can begin it with either a forward or backward slash:
either / or \ will work. However, within a macro expression, you MUST use '/': write CommentsAny line beginning with // is a comment and will be ignored.
Any text between /* and */ is also a comment. This kind of comment can span multiple lines.
Types of MacrosExpression Macros
These are triggered when you hit the Return key and the trigger expression begins the line. An expression with
spaces in it will not work as a trigger, because only the first word of the line will be examined to see if it matches. Examples
Replacement Macros
These are triggered when you are typing and hit any key that isn't
a letter or a number, and the trigger is the last word before the
insertion point. If you hit return, the last word of the line is
compared to trigger. You can type a space or a return without
triggering a replacement macro by holding down the control key
while typing them. Replacement macros end execution immediately, so
you cannot use any commands that cause a delay, nor any return (\r)
characters. One good use of replacement macros is for
abbreviations that automatically expand themselves, as in the first
two examples below.Examples
Key Macros
Key macros are triggered by hitting the specified key combination. If a key combination would normally
do something and you define a macro for it, your macro will be used instead of the normal action.
For example, a command-p macro would override the
Command menu "Pull" that's usually attached to that key combination.
For most keys, the character that is printed when you type the key is the key name, but some have special names:
Keys:
Modifiers:
Option KeyUsing the option modifier with letters is a bit tricky because typing option-letter often changes the letter. For example: On most U.S. systems and keyboards, typing option-s actually produces the single character ß. So to use option-s as a macro key, you will need to use the option-character in the macro definition. That is, macros defined like this will set the text to "this succeeds" when you hit option-s:
The "Click" KeysThe "click" key lets you make clicking on a player with certain modifiers do something. The macro executes if you click on a player in the players' window or in the game window. The one exception is that a macro defined for a plain click with no modifiers won't work in the Players window (this would override you being able to use the Players window!).OS X Only: If you have a multi-button mouse, you can also use the names "click2", "click3", etc. These are triggered when you press the corresponding mouse button. You may need to experiment a bit to find out what the button numbers are for your mouse. "Click2" is almost always the secondary or right button, but beyond that, the ordering is hardware-defined. You'll have to do some tests to figure out which buttons are which for your mouse. "Right-click" is a synonym for "click2". Examples
The "Wheel" KeysOS X Only: If you have a scroll-wheel mouse, you can write macros that are triggered by moving the wheel. If you assign a macro to the "wheelup" pseudo-key, it'll be triggered when you scroll up; "wheeldown" works in the other direction. You can also assign macros to "wheelleft" and "wheelright", but they'll only work if: (a) you really do have a horizontal wheel, or (b) you're using OS X 10.2 or later, and you hold down the shift key while turning the regular (vertical) wheel.Function Macros
Function macros are triggered by a "call" command from within another macro. See the command section
for more information.
The "@login" MacroIf you have a function macro called "@login", it will run automatically when you log into the game, or whenever you choose the "Reload Macros" menu item.Examples
AttributesAn attribute is a line that you can put in a macro to change how it behaves. An attribute is not executed at a certain place in a macro; rather, it controls how CL and the macro interact. Therefore, you can put an attribute anywhere in a macro. All attributes begin with a $ character.Supported Attributes
ExamplesA pair of macros that let you hold shift and click if you want to use click toggles mode and click normally for click and hold movement: VariablesA variable is the programming term for a name that is set to another value. For example, we might have a variable called race; we can set this variable to hold the value "Thoom". Now whenever we refer to the name, race, "Thoom" will be substituted. Later we could change race to be "Sylvan". Now we could do exactly what we did before, but every reference to race will now be substituted with "Sylvan" instead.Global VariablesThese variables are defined the same for every macro that you run. To define one, use a set statement that isn't inside any macro.
Notice that if the variable is text, you enclose it in quotation marks; and if it is numerical, you
don't. Now we can use these values in any macro:
This will output:
Local VariablesThese variables are defined only for the macro they are declared within. You declare them the same as you would a global variable, except they are within a macro.
This will output:
Now assume that we didn't have those global variable declarations described above, but we had these
macros named vartest1 and vartest2 in the same macro file:
vartest1 will output:
In vartest1 the variables who and num are not defined, so they count as nothing!
Setting Global Variables from Within a MacroSuppose you had a global variable named who and you wanted a macro to be able to change it. To do this you use the setglobal command from within a macro:
Now if you use vartest1 you get:
But now if you type
the set1 macro executes, changing the global variable, so that when you do vartest1 again you get:
Global and Local Variables with the Same NameThis is best shown by example. You can have the same variable name for both a global and a local variable. If you change the local one, the global one won't be affected; it will remain the same in all other macros besides the one in which there's now a local variable with the same name.
Now if you use set1 you get:
But now if you use vartest1 you still get:
CL-Defined VariablesBy setting some special variables you can control how CL loads and uses macros. By putting others in your macros you can get information about your character or other characters. All special variables start with an @. The following is a list of all of these variables. @env Variables Words and LettersBy appending these trailers on the end of any variable you can refer to words or letters of that variable's value. .word[n] CommandsIf a line starts with a command word, then Clan Lord takes special action (described below for each command). Otherwise, the words in the line are just interpreted as text. You can only have one command per line. You can use variables for any of the parameters of the various commands.Text
If the first word of a line is not another command, then Clan Lord assumes this line is text.
Any text in quotes is just inserted. Each item which is not in quotes is assumed to be a variable, and the value of the variable is inserted. As a macro
executes, it concatenates text until it reaches an end-line character "\r", at which point it sends the text it has saved and pauses one frame. If there
is text after the last "\r" of the macro, then this text is inserted into the text field. This means that if there are no "\r" characters, the text
is simply inserted into the typing area, without being sent to the server.
Examples
Pause
Pauses the macro for <number> frames. Examples
Set
Sets the local variable or does an operation on its current value (see the variable section). The + operator can be used to concatenate two string variables, but all other operators assume numeric variables and give a numeric result.
SetGlobal
Sets a global variable or does an operation on its current value. Examples
Call
Executes the given macro function at this point in the macro. This function and the calling function share local variables. Examples
Random
Randomly chooses one of the choices to execute from the list. If <option> is "no-repeat", then it will never choose the same one twice in a row, unless there's only one choice total (in which case "no-repeat" is impossible). If you don't specify "no-repeat", then each alternative is equally likely. Examples
If
This statement executes the commands after an "if" if the comparison is satisfied. If it isn't
it goes to the next else statement. The expressions may be numerical or strings (in which case < and > are interpreted as "is a substing of"). Examples
Label
Sets a place in a macro as a possible target for a goto command. Goto
Goes to the specified label and continues execution from there. With goto and label commands
you can make loops (If you ever get in an infinite loop, remember holding down control-escape stops all macros) Examples
Message
Works just like the text command, but the output is shown in the sidebar. It isn't necessary to end the output with a "\r" character though. (Naturally it is only shown in YOUR sidebar, and this won't show up in movies.) Examples
|