I have kg panels that I am setting up for the addon
Broker_StatsNow. The addon is broken down into sub addons (Spells, Ranged, Melee, Tank, PVP) and each of those has a LDB display for each stat. (I am using
StatBlockCore as my LDB display). I have it set up so the panel shows only in combat and it hides the ldb plugins when the panel isn't visible. This works great, as long as the ldb plugins are active. When they are not, I get this error.(I only have 2 set up so far... one for spells and one for ranged stats)
Code:
1x <string>:"ranged_OnEvent":13: attempt to index global "StatBlockCore_RangeAP" (a nil value)
<string>:"ranged_OnEvent":13: in function <string>:"ranged_OnEvent":1
Locals:
I get one for StatBlockCore_SpellPower if I am on my hunter and the spell stats are inactive.
The panels are not parented to the addons because when I try, I get a warning about a loop and it breaks.
Here is how they are scripted:
On Load:
Lua Code:
local _,class = UnitClass("player")
self:SetBackdropBorderColor(RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b)
self:RegisterEvent("PET_BATTLE_OPENING_START")
self:RegisterEvent("PET_BATTLE_CLOSE")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:Hide()
On Event:
Lua Code:
if event == "PET_BATTLE_OPENING_START" then
self:Hide()
elseif event == "PET_BATTLE_CLOSE" then
self:Show()
end
if event == "PLAYER_REGEN_ENABLED" then
self:Hide()
elseif event == "PLAYER_REGEN_DISABLED" then
self:Show()
end
StatBlockCore_RangeAP:SetParent(kgPanels:FetchFrame("ranged"))
StatBlockCore_RangeCrit:SetParent(kgPanels:FetchFrame("ranged"))
StatBlockCore_RangeHaste:SetParent(kgPanels:FetchFrame("ranged"))
StatBlockCore_RangeMastery:SetParent(kgPanels:FetchFrame("ranged"))
It is scripted the exact same way for the spells (except using the LDB plugin frame names for spell stats). I also tried making the script dependent on the addon but that didn't work either.