Mak'ro Basics

Version 1.1 / updated on 2002JA31
Return to the main guides index

Note: due to the nature of what is discussed here, some (well, ok most) of the comments are OOC in nature. I tried to limit this as much as I felt comfortable with. Another introduction on Mak'ros can be found here. For a more complete reference check here instead.

There is a repository of macros made by exiles, all sorts of macros, small and big, to do just about anything. You can look at it here.

About this scroll on macros

[More OOC comments are written between brackets];
Snippets of code that should appear in the macro file will be written this way;
CL commands that are typed in the CL client application will be in this font.


Introduction

Mak'ros can be used to help with many simple and complex tasks that a character wants to accomplish in the lands. It can range from a simple action, like smiling, to a very complex one, like automatically sharing friends according to specific rules and priorities. Whatever way you want to use them, there are a few basic things you should be aware of before you start writing mak'ros.

Whenever you leave the library a scroll with your name is read [a file with the character's name in the "/macros" directory is loaded by the CL client application]. This scroll is a simple text [file] and can be written in any manner [edited in any application that can work with text]. Other scrolls can also be read, for example a scroll named "default" is usually read also [the statement include "Default" is what links other files, more on that later].

The "default" scroll contains some abbreviations for common commands [for example typing mm will do the same as /money, and aa will do the same as /action.

I strongly suggest to modify the "Default" scroll's abbreviations for /think and /thinkto. They are set respectively at t and tt and it is easy to type t by mistake while meaning to use tt and what was meant as a private message becomes a broadcasted message (which can be very embarrassing). I use tg for /think (think general) and tt for /thinkto. To make this modification open the "Default" scroll and change:

"t" "/think " @text "\r"

to

"tg" "/think " @text "\r"

Let's look at that statement and how it works: The first statement, "tg", is the trigger while the rest, "/think " @text "\r", is the instruction. What this mak'ro does is this: the user for example types tg Anyone knows where Drablak is fallen? and hits return. The instruction in the mak'ro is to execute the command /think followed by whatever was typed after the tg trigger (and which is contained in the variable @text) and then to send a return (the \r is the instruction for return). So this is the equivalent of having typed:

/think Anyone knows where Drablak is fallen? (Return)

So a mak'ro is basically a trigger followed by one or more instructions. Let's take a closer look at triggers first.

Triggers

Triggers can be almost anything you want, but be careful not to use something that you might type by mistake. Choosing "the" for instance would be foolish, but "/the" would probably be ok, although I would not recommend it. Choose something you'll remember too, although you can make yourself a help system (I had to since I have too many mak'ros and not enough memory).

There are basically four types of triggers.

Text Triggers

Text triggers are like those mentioned above, such as "tg", "aa", or "/the". Those are written between quotation marks in the mak'ro [file]. To use them in CL you type only what is inside the quotation marks and then return. You can use a slash to distinguish from a common word, as in the "/the" example, but make sure not to use commands already used by CL.

Key Triggers

You can also define keys as triggers. F-keys are very handy, for instance, for mak'ros that need to be accessed quickly or very often. Key triggers are not put between quotation marks. You can combine keys by adding a dash between the keys. Examples of key triggers are:

control-numpad-2 "/yell South\r"

f13 "\EQUIP " primaryWeapon \r

PageUp "yes \r"

End "Thanks \r"

Key triggers can include mouse clicks also, as in
control-option-click
{
"/equip chain\r"
pause 2
"/use " @clicksplayer "\r"
}

System Triggers

I know of only one system trigger but there might be more. The one I know is @login (used without quotation marks) which can trigger instruction automatically when you wake up.

User-defined Triggers or Functions

Those are not meant to be used directly from the CL client, but are meant to be used by other mak'ros (as a function or sub-routine call). Those triggers are not put within quotation marks and can be any word that is not predefined (such as key triggers for example). I try to use descriptive names for triggers but anything will do. User-defined triggers are usually used with multi-lines instructions, since it would probably not be worth it to bother with a sub-routine for a single instruction. They are used for functions that can be called from more than one mak'ro or for clarity. An example of a user-defined trigger is restore_item in the following:
restore_item
{
if saveItem != @my.right_item
"\equip " saveItem \r
end if
}

Instructions

Instructions can be many things, short or long. If a single instruction is triggered you simply put it after the trigger on the same line. Multiple instructions are placed within curly brackets { }, with one instruction per line. Here is an example that shows a multi-instruction mak'ro. I will explain how it works first, then I'll look at each statement in more details. This is a simple mak'ro that uses some basic instructions.
@login
{
set count 0
label top
pause 1
set count + 1
if count != 50
goto top
end if
call do_sharecads
}

The above example will be triggered automatically on awakening. The first line defines a local variable count and sets it to 0. The second line defines a label, or jump point, for the loop back call that we'll use. The third line takes a pause of one frame refresh. The fourth line increments the variable count by one. The sixth line checks if the variable count reached 50, != means not-equal and if the comparison is true the following instruction(s) will be executed. If the condition is false the next instruction executed is the one immediately following the end if statement. In this case count equals 1 the first time the if count != 50 instruction is executed, so the following instruction is executed. In this case goto top, which means that the next instruction that should be executed is the one following immediately the label top. So this basically pauses, increment a variable and loop back 50 times before continuing with the mak'ro (when count equals 50). The mak'ro then calls a sub-routine called do_sharecads.

This mak'ro executes upon awakening, and it does basically only one thing, that is to call do_sharecads, but it first waits a short time so that news, clanmates, and friends lists can be displayed. There are more efficient ways to do this of course, but this illustrates a number of basic instructions.

Variables

Something that is very useful in mak'ros are variables. Variables are like containers that are used to hold a piece of information that is likely to change each time the mak'ro is used. There are three types of variables: system variables, local variables, and global variables. There are also three things you can do with a variable: define it, modify it, and use it. We'll see each of those in details.

System Variables

System variables are predefined by the client application. Their content is updated by the system, so you usually don't assign them values or even modify them, you simply use them. They are there to help writing mak'ros that interreact with the interface. By convention, all system variables starts with @. In mak'ros, the @ character is just like another letter used in a variaable name (i.e., it is not an operator as in some programing languages) Here are some examples of system variables.

More to come...


Drablak. Return to Drablak's Hideaway
Quick Navigation: Journal Travels Guides History Scrapbook What's New
For more information or comments, please send enchanted mail to Drablak at pucks dot org..