This guide is intended to give a quick and easy introduction to basic macro syntax. This should enable you to create various macros for your own use without having to wait for forum responses.
The start of every macro is a slash command. For the purpose of this guide, we will be using /cast. However, any slash command that accepts macro options can be used.
This is how your basic macro looks like:
Code:
#showtooltip
/cast Spell1
This macro contains of two lines. The first line is preceded by a #. This means it contains display information for bar addons.
The line #showtooltip means that the tooltip for the first spell in the macro should be displayed on mouseover, and if the icon is set to the question mark icon, it will also update accordingly.
The second line is the main macro. /cast Spell1 is a slash command that would cast the spell named "Spell1".
Next, we have to get to the "intelligent" part of the macro.
Macro options
Every macro option specified in brackets is a if statement. The argument right after the brackets is the argument used if the macro option is met, a semicolon is a logical ELSE(IF) statement.
If the options for the first argument are met, the rest of the line is never interpreted. The first match will always be used.
Code:
#showtooltip
/cast [option]Spell1; Spell2
If [option] is met (returns true), Spell1 is cast - otherwise Spell2 is cast.
This can be expanded:
Code:
#showtooltip
/cast [option1]Spell1; [option2]Spell2; Spell3
If [option1] is met, it casts Spell1, otherwise if option2 is met, it casts Spell2, otherwise it casts spell3.
You can also chain together multiple macro options as a logic AND by using a comma.
Code:
#showtooltip
/cast [option1, option2]Spell1; [option3]Spell2; Spell3
If both option1 and option2 are met, Spell1 is cast. Otherwise, if option3 is met, Spell2 is cast. Otherwise, Spell3 is cast.
You can chain multiple options together by simply listing them one after another.
Code:
#showtooltip
/cast [option1][option2]Spell1; Spell2
If either option1 or option2 is met, Spell1 is cast. If neither is met, Spell2 is cast.
Any option can be reversed by adding "no" in front of it.
Code:
#showtooltip
/cast [nocombat]Spell1; Spell2
Cast Spell1 if [combat] is not true, otherwise cast Spell2.
This is equivalent to:
Code:
#showtooltip
/cast [combat]Spell2; Spell1
Some options have sub-options. For example, the [mod] option has three sub-options. shift, alt and ctrl. If you just specify [mod], that means that any of the sub-options needs to be true in order for the option to be true.
You can specify a specific sub-option that needs to be met by using the following syntax:
If you only want to cast Spell1 while shift is down, use this:
Code:
#showtooltip
/cast [mod:shift]Spell1; Spell2
Now you can use what I described above to stick together all kinds of constructs.
Code:
#showtooltip
/cast [mod:shift, combat]Spell1; [mod:shift]Spell2; [combat]Spell3; Spell4
If shift is down during combat, cast Spell1. If shift is down but we are not in combat (otherwise Spell1 would have been cast, this is why we don't have to specify [nocombat]), cast Spell2. If we are in combat but shift is not down (otherwise Spell1 would have been cast, this is why we don't do [nomod:shift]), Spell3 is cast. If we are neither in combat nor shift is down (either combination of those would trigger one of the earlier ones), Spell4 is cast.