I have this macro that works:
/script global.targetName = UnitName("target")
/script print(targetName)
It sets the global variable, targetName, to whomever I’m targeting, and then displays their name in my chat frame. Works perfectly.
However, when I run this code:
/script global.tankName = UnitName("target")
/script print(tankName)
It does not seem to want to set the variable, and is showing “nil” in the chat frame.
Any ideas on why “targetName” works, but “tankName” does not? I mean, it’s literally the only thing that changes between the two macros…
UPDATE:
Well, despite Capella’s unhelpful remarks, I found out how to set a global variable (for those who may be new to macros like myself.
It seems that “global” in:
/script global.tankName = UnitName("target")
has been causing some problems, but if I run it without “global”:
/script tankName = UnitName("target")
it seems to work fine. I have one macro setting the tankName variable, and another macro using the tankName variable, so I’m assuming it’s automatically a global variable.