How can I write a macro in WoW that depends on my spec?

I'm a Paladin. My specs are Protection and Retribution. I want to write a macro that basically says:

if Protection
  mark target with skull
else
  /assist

Then I can replace my assist key with it to quickly be able to mark targets while tanking, but assist the tank when DPSing.

Thanks.


Solution 1:

You can indeed do several things depending on your spec. To achieve your example goal, try the below. This uses a combination of macro conditionals and Lua scripting.

/script if (GetActiveTalentGroup()==1) then SetRaidTarget("target", 8); end;
/assist [spec:2]

What this says is, if I'm in spec 1, then set raid target 8 (skull). Then, assist my target, if I am in spec 2.

See Macro Conditionals for full documentation on the conditional statements you can use.

Solution 2:

You should be able to use GetActiveTalentGroup() which returns the active talent group (1 or 2).

It takes two parameters isInspect and isPet, for what you want to do though you'd probably want them both to be false.

http://www.wowwiki.com/API_GetActiveTalentGroup