I have a macro idea and I need someone to help write it!

I stopped on

1st macro:

/SET "something what ident that it is variable" %t

2nd macro:

/target "variable?" 

/run SetRaidTarget("target", 1)

Of course it could be optimised etc. etc.

You set a specific mob for variable and then use it name looking for more of those.


2 Answers 2


You could be a little more specific about what you want. Perhaps an example of a situation where this macro could be used would help?

There is no way to "store" a target for future use in an arbitrary variable. You can't do like "Set my target as the KILLTHIS variable" and then later "Target KILLTHIS."

The methods available are:

  • Target
  • Focus
  • Direct access via name ("Ragnaros")
  • Indirect access ("party2target," "targettarget," "pettarget")

There is no way, for example, to set a Skull raid icon on something and then later target it by virtue of it simply having the Skull icon over it. In order to do something like that, you would need to store the mob in question as a Focus, then later target your Foucs. A lot of Crowd Control macros use Focus for exactly this purpose.

If this is the thing you are trying to do, then I could go into more detail on how to use Focus to store off a target for later use. But I suspect the answer to what you are trying to ask is "Sorry, you cannot do that."

  • well, not by using macros anyway. if the OP wanted to write their own add-in it should be possible.
    – Xantec
    Jul 5, 2011 at 11:49
  • I ask a command or line whitch sets variable, and then how to use it :D u lock 1 mobs name - and with other macro is used for looking moar of them
    – Ishban
    Jul 5, 2011 at 14:17
  • @Xantec - No, it's still not possible to do something like 'Target whatever mob has a skull' with an addon. The same limitations that restrict that sort of functionality from macros affect addons as well. Jul 6, 2011 at 2:21

I hate to be the bearer of bad news, but what you are asking for cannot be done, as it runs afoul of Blizzard's anti-botting/-scripting security measures.

The first part of the problem is that all of the targeting functions are protected, meaning they can only be called by "secure" code (i.e. the built-in interface), not by addons or via the /run command. As a result, changing your target can only be done via built-in slash commands like /assist and /target.

The second part of the problem is that none of those commands support the use of Lua variables (those are what you can set in a macro). Instead, they accept either a literal unit name (e.g. Fluffy Bunny) or a "unit ID" (which work like variables, but are set by the game's internal code).

Finally, raid target icons can only be set on unit IDs as well, making it impossible to set a raid target icon on a unit whose name isn't stored in the macro (or available via a unit ID).

There are a couple of ways to work around this, but they aren't great. The first would be to write an add-on which dynamically generates macros containing the desired name. The macro couldn't be generated in combat, but it could be run. i.e. you could only run "1st macro" before combat, but then run second whenever you like.

Alternatively, you could create a macro with a large number of /targetexact lines — one for each mob you might wish to run the macro on. /target commands "fall through" if no valid target is found, meaning it would use the first available mob in the list.

Normally, you would be able to use your focus target for this, but it tracks real, individual mobs. You can't use it to target other mobs of the same name/type.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .