Take the 2-minute tour ×
Arqade is a question and answer site for passionate videogamers on all platforms. It's 100% free, no registration required.

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 :)

share|improve this question
    
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. –  LessPop_MoreFizz Jan 15 '11 at 23:42
    
Any particular reason you need to assign a variable in a macro? I've never seen that done before. –  Anna Lear Jan 16 '11 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. –  LessPop_MoreFizz Jan 16 '11 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. –  Anna Lear Jan 16 '11 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 '11 at 15:26

4 Answers 4

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.
share|improve this answer
    
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 '11 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 '11 at 4:10

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"]
...
share|improve this answer
    
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 '11 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 '11 at 14:52
    
@Cybrix: I believe it'll return the target's name as it is. –  Stuart Pegg Feb 1 '11 at 15:05
    
@Stuart, allright I can't wait to test it! –  Cybrix Feb 1 '11 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 '11 at 0:40

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
share|improve this answer
    
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 '11 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 '11 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 '11 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 '11 at 17:12
    
So, just split it up? Add the character name in chat then run the macro? –  Delameko Jan 20 '11 at 8:55

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

share|improve this answer
    
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 '11 at 20:05
3  
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. –  Matthew Read Feb 10 '11 at 4:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.