Hello,
I want to get class & spec of EnemyUnit in BG ( "target", "raid1target"...
the function print correctly the class & Spec but returns nil,nil,nil when I want to use it in an other function.
e.g.
local unit = "target"
local enemyRole,enemySpec,enemyClass = jps_EnemySpec_BG(unit)
print("|cFFFFff00",enemyRole,enemySpec,enemyClass)
returns nil,nil,nil
I don't understand why?
Lua Code:
function jps_EnemySpec_BG(unit)
if not UnitExists(unit) then unit = "player"
else unit = "target" end
if CheckInteractDistance(unit,1) then
NotifyInspect(unit)
end
local f=CreateFrame("Frame")
f:RegisterEvent("INSPECT_READY")
f:SetScript("OnEvent",function(self,event,...)
if event == "INSPECT_READY" then
local specID = GetInspectSpecialization(unit)
local enemySpec = select(2,GetSpecializationInfoByID(specID))
local enemyRole = select(6,GetSpecializationInfoByID(specID))
local enemyClass = select(7,GetSpecializationInfoByID(specID))
print(specID,"-",UnitName(unit),"is",jps_tableSpec[specID],"-",enemyClass,"-",enemySpec,"-",enemyRole)
end
f:UnregisterEvent("INSPECT_READY")
end)
return enemyRole,enemySpec,enemyClass
end
Ps jps_tableSpec is a simple table of differnts spec
Lua Code:
jps_tableSpec =
{
[250]="Blood", [251]="Frost", [252]="Unholy", [102]="Balance", [103]="Feral",
[104]="Guardian", [105]="Restoration", [253]="Beast Mastery", [254]="Marksmanship",
[255]="Survival", [62]="Arcane", [63]="Fire", [64]="Frost", [268]="Brewmaster",
[270]="Mistweaver", [269]="Windwalker", [65]="Holy", [66]="Protection",
[70]="Retribution", [256]="Discipline", [257]="Holy", [258]="Shadow",
[259]="Assassination", [260]="Combat", [261]="Subtlety", [262]="Elemental",
[263]="Enhancement", [264]="Restoration", [265]="Affliction", [266]="Demonology",
[267]="Destruction", [71]="Arms", [72]="Fury", [73]="Protection",
[0]="Unknown Spec"
}