10

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 works but what if I want to assign gank variable with the current target?

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

More specifically: 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.

How can I do this, if it's possible?

7
  • Just to clarify, are you looking to cast the spell Heal at your current target? Because for the life of me, I've never seen the command '/script heal' in a macro. Jan 15, 2011 at 23:42
  • Any particular reason you need to assign a variable in a macro? I've never seen that done before.
    – Adam Lear
    Jan 16, 2011 at 0:40
  • 1
    @anna %t can be used for a variety of things. Macroing "I Cast [spell] on %t!" along with a spell is the most popular/common example. I'm not sure what exactly Cybrix is trying to do with it here though. Jan 16, 2011 at 1:05
  • 1
    @LessPop_MoreFizz I know that. I was commenting on the variable assignment. Why not just keep using %t everywhere it's needed in the macro? Not like it's going to change during its execution.
    – Adam Lear
    Jan 16, 2011 at 2:32
  • 1
    To those that don't understand, he wants to create a macro like "/target tank_name; /cast Heal;" then at the start of each group he can run "/script tank_name"
    – Delameko
    Jan 18, 2011 at 15:26

4 Answers 4

2

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
7
  • Close, but I believe he wants GetUnitName("target") -- "player" would be the name of the character he is playing not the selected corpse.
    – ghoppe
    Jan 18, 2011 at 20:18
  • Also, there is no need for the variable in your example. You could just UnitIsDeadOrGhost("target") I would change it to ChatFrame1:AddMessage(name.." is Dead"); etc.
    – ghoppe
    Jan 18, 2011 at 20:19
  • Hi, indeed I want it to be dynamic. With macro1 you store your current target in a variable. And with macro2 you check if that player "exists".
    – Cybrix
    Jan 19, 2011 at 17:11
  • Also, if the target is a player and actually dead and walking back (spirit released), the corpse isn't clickable.
    – Cybrix
    Jan 19, 2011 at 17:12
  • So, just split it up? Add the character name in chat then run the macro?
    – Delameko
    Jan 20, 2011 at 8:55
1

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

2
  • Why was this modded down? Though not answered with implementation specifics, this answer is not off topic or incorrect, and aims to be helpful. Modding down an answer just because it wasn't the answer you were looking for puts a cramp on people's desire to try and help.
    – Wes P
    Feb 9, 2011 at 20:05
  • 4
    It wasn't "modded" down, it was voted down. There are many reasons an answer may be voted down, it doesn't need to be incorrect. Possibly the voter felt that "fix it yourself" was not helpful, even though there were resources provided for doing so. Feb 10, 2011 at 4:17
1

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.
2
  • I edited my question. Apparently you forgot to read below: Edit 2011-02-04. I renamed the heal variable into gank so it wont confuse anymore. It's not about healing, the main question: How to store target name in a variable in a macro.
    – Cybrix
    Feb 5, 2011 at 3:58
  • 1
    I did read below the edit. :P My solution effectively does as you ask, as your 'focus' is intended to be a variable that stores a target of your choice. Your reluctance to accept it as a solution leads me to believe that you are needing more than one variable stored at a time for the purposes of your use-case. If that is so, please clarify your question. It might help to have more specific details as to what you're trying to do than a general statement of wanting to store a target's name in a variable.
    – Shaun
    Feb 5, 2011 at 4:10
0

From the clarification, it appears you want to store a global variable for use between macros, as in:

Macro 1: Store target's name

Macro 2: Check if stored target is alive

It seems this is accomplished using:

Macro 1:

_G["heal"] = UnitName("target")

Macro 2:

local heal = _G["heal"]
...
7
  • You perfectly understood the question. Though, I haven't tested the code yet. I will as soon as I get back home. Thank you for your answer!
    – Cybrix
    Feb 1, 2011 at 14:51
  • Does the target parameter to UnitName is your current target or I'll have to edit that macro and replace "target" by the name ?
    – Cybrix
    Feb 1, 2011 at 14:52
  • @Cybrix: I believe it'll return the target's name as it is.
    – Stu Pegg
    Feb 1, 2011 at 15:05
  • @Stuart, allright I can't wait to test it!
    – Cybrix
    Feb 1, 2011 at 15:16
  • Hmm sadly it's not working. I've tried Macro1: /script _G["gank"] = UnitName("target"); and Macro2: /script local gank = _G["gank"]; /run if UnitIsPlayer(gank) then UIErrorsFrame:AddMessage("Player " .. gank .. " is ALIVE!", 1.0, 0.5, 0.0, 3) end;
    – Cybrix
    Feb 2, 2011 at 0:40

You must log in to answer this question.

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