World-of-warcraft – How to store target name in a variable in a macro

world of warcraft

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 🙂

Best Answer

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