Thread Tools Display Modes
09-16-16, 10:27 AM   #1
Nivle
A Defias Bandit
Join Date: Sep 2016
Posts: 2
SUF Arena spec tag

im trying to create a Shadowed Unit frames tag for arena spec so far i managed to only get "NONE"
Code:
function(unit, unitOwner)
    local currentSpec = GetArenaOpponentSpec(i)
    for i = 1, 5 do -- Getting the ArenaID of the target
            if UnitIsUnit("target", "arena"..i) then
              TargetArenaID = i
              break
            end
    end
    local currentSpecName = currentSpec and select(2, GetSpecializationInfo(currentSpec)) or "NONE"
    return currentSpecName
end
I'm a complete newbie to LUA so iam shooting in the dark, any help would be amazing.
  Reply With Quote
09-17-16, 09:39 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You're most of the way there. The problem is on your second line: you pass "i" to GetArenaOpponentSpec, but you haven't defined the "i"variable yet at that point.

Some other minor points:
- On line 5, you define a (global, bad) "TargetArenaID" variable, but you never use it.
- You don't need to assign a value to a variable in order to return it; you can just return it directly.

This should work:

Code:
function(unit, unitOwner)
    local currentSpec
    for i = 1, 5 do
        if UnitIsUnit(unit, "arena"..i) then
            currentSpec = GetArenaOpponentSpec(i)
            break
        end
    end
    return currentSpec and select(2, GetSpecializationInfo(currentSpec)) or "NONE"
end
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 09-18-16 at 01:09 PM.
  Reply With Quote
09-17-16, 02:13 PM   #3
Nivle
A Defias Bandit
Join Date: Sep 2016
Posts: 2
thank you so much for giving the time, but unfortunately still returning blank :/
  Reply With Quote
09-17-16, 02:48 PM   #4
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
No idea how SUF works, but shouldn't you be using the unit variable somewhere?
__________________
Grab your sword and fight the Horde!
  Reply With Quote
09-18-16, 01:07 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Good point. You probably want to change this line:

Code:
if UnitIsUnit("target", "arena"..i) then
to this:

Code:
if UnitIsUnit(unit, "arena"..i) then
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SUF Arena spec tag


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off