I having problems hiding BazookaBar_1 a bar from the addon Bazooka. I get the error below even though the frame actually hides and shows based off my saved variable.
topmenu.lua:21: attempt to index global "BazookaBar_1" (a nil value)
I've tried
Lua Code:
local b1 = _G["Bazooka.BazookaBar_1"]
declared at top of page and within the function and get the same error. I think it was actually detecting it as a local variable at some point I don't remember how I had it but I was getting a different error about indexing a upvalue. I thought I was on the right track there so I added Bazooka as a dependency to make sure it was loaded first but that was no fix. What am I doing wrong in my topmenudisplay() function?
Lua Code:
local aegerUI = ...
local MEDIAPATH = "Interface\\AddOns\\aegerUI\\Media\\"
local classcolor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[(select(2, UnitClass("player")))]
local topmenu = CreateFrame("Frame", "topmenu", UIParent)
topmenu:RegisterEvent("ADDON_LOADED")
topmenu:RegisterEvent("ONUPDATE")
topmenu:RegisterEvent("ONLOAD")
topmenu:Hide()
local topmenuborder = CreateFrame("Frame", "topmenuborder", UIParent)
topmenuborder:RegisterEvent("PLAYER_REGEN_ENABLED")
topmenuborder:RegisterEvent("PLAYER_REGEN_DISABLED")
topmenuborder:Hide()
function topmenudisplay()
if TopmenuShow == 1 then
topmenu:Show()
topmenuborder:Show()
BazookaBar_1:Show()
else
if TopmenuShow == nil then
topmenu:Hide()
topmenuborder:Hide()
BazookaBar_1:Hide()
end
end
end
topmenu:SetScript("OnEvent", function(self, event, ...)
topmenudisplay()
end)
local function flip(texture,horizontal)
local ULx,ULy,LLx,LLy,URx,URy,LRx,LRy = texture:GetTexCoord()
if horizontal then
texture:SetTexCoord(URx, URy, LRx, LRy, ULx, ULy, LLx, LLy)
else
texture:SetTexCoord(LLx, LLy,ULx, ULy, LRx, LRy, URx, URy)
end
end
topmenu:SetScript("OnShow", function(self)
self:SetScript("OnShow", nil)
PetBattleFrame:HookScript("OnShow",function() self:Hide() end)
PetBattleFrame:HookScript("OnHide",function() self:Show() end)
local tmdisplay = self:CreateTexture(nil, "BACKGROUND")
tmdisplay:SetSize(500, 36)
tmdisplay:SetPoint("TOP", UIParent, "TOP",0 ,3)
tmdisplay:SetPoint("CENTER", UIParent, "CENTER")
tmdisplay:SetTexture(MEDIAPATH .. "topmenu")
tmdisplay:SetVertexColor(0, 0, 0, .5)
flip(tmdisplay,false)
end)
topmenuborder:SetScript("OnShow", function(self)
PetBattleFrame:HookScript("OnShow",function() self:Hide() end)
PetBattleFrame:HookScript("OnHide",function() self:Show() end)
local tmborderdisplay = self:CreateTexture(nil, "BORDER")
tmborderdisplay:SetSize(502, 46)
tmborderdisplay:SetPoint("TOP", UIParent, "TOP", 0, 10)
tmborderdisplay:SetPoint("CENTER", UIParent, "CENTER")
tmborderdisplay:SetTexture(MEDIAPATH .. "topmenuborder")
tmborderdisplay:SetVertexColor(classcolor.r, classcolor.g, classcolor.b, 1.0)
flip(tmborderdisplay,false)
topmenuborder:HookScript("OnEvent", function(self, event)
if event == "PLAYER_REGEN_DISABLED" then
tmborderdisplay:SetVertexColor(1, 0, 0)
elseif event == "PLAYER_REGEN_ENABLED" then
tmborderdisplay:SetVertexColor(classcolor.r, classcolor.g, classcolor.b, 1.0)
end
end)
end)
SlashCmdList.TOPMENUSHOW = function()
TopmenuShow = 1
ReloadUI()
end
SLASH_TOPMENUSHOW1 = "/tmshow"
SlashCmdList.TOPMENUHIDE = function()
TopmenuShow = nil
ReloadUI()
end
SLASH_TOPMENUHIDE1 = "/tmhide"