How do I store target name in a variable in a macro?

This one must be an easy, but I can't find it anywhere... I've been looking around for a while now.

/script gank = "Evyna";

This work but what if I want to assign gank variable with the current target ?

I've tried /script gank = %t; but unfortunatly it's not working.

Any tips?

Edit 2011-02-04 :

I'm adding a bounty now and I'll try to be more specific with my question:

I would like to create a macro that once clicked, my current target name is assigned in a variable. After that, I could use my second macro which I simply click (or spam?) and then, the character's name is taken from the variable and check if he's alive and display a message accordingly. (I can do the second macro).

In short: I need to assign my target's name in a global variable that I can use later in a second macro.

Thank you :)


In chat:

/run name = "Theplayersname";

Or a click-to-set character macro:

/run name = GetUnitName("target");

Macro:

/run if (UnitIsDeadOrGhost(name)) then ChatFrame1:AddMessage("Dead"); else ChatFrame1:AddMessage("Alive"); end

The WOW Wikia macro guide has been helpful for me. For your question the Targeting and Help/Harm sections would be of particular help.


I think you're over-complicating this series of macros. Based on the use-case in your edit, I would recommend you set your focus to the person you want to heal, then change your macros to use your focus.

/focus target

That macro will set your current target to your 'focus'. Think of 'focus' as a variable that can hold one target as a value.

Now, your other macros can use your focus as a valid target:

/cast [@focus] Flash Heal

Ninja edit: If you look at the "Key Bindings" menu in WoW, you can bind a key to set your current target as your focus. Then, you don't even need the first macro:

  • Target a player
  • Hit your "set focus" key.
  • Use your other macros for maximum awesome.