View Single Post
09-05-13, 11:23 AM   #1
almty1
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 13
Issue hiding a BazookaBar

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:
  1. 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:
  1. local aegerUI = ...
  2. local MEDIAPATH = "Interface\\AddOns\\aegerUI\\Media\\"
  3. local classcolor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[(select(2, UnitClass("player")))]
  4.  
  5. local topmenu = CreateFrame("Frame", "topmenu", UIParent)
  6. topmenu:RegisterEvent("ADDON_LOADED")
  7. topmenu:RegisterEvent("ONUPDATE")
  8. topmenu:RegisterEvent("ONLOAD")
  9. topmenu:Hide()
  10.  
  11. local topmenuborder = CreateFrame("Frame", "topmenuborder", UIParent)
  12. topmenuborder:RegisterEvent("PLAYER_REGEN_ENABLED")
  13. topmenuborder:RegisterEvent("PLAYER_REGEN_DISABLED")
  14. topmenuborder:Hide()
  15.  
  16. function topmenudisplay()
  17.  
  18. if TopmenuShow == 1 then
  19. topmenu:Show()
  20. topmenuborder:Show()
  21. BazookaBar_1:Show()
  22. else
  23. if TopmenuShow == nil then
  24. topmenu:Hide()
  25. topmenuborder:Hide()
  26. BazookaBar_1:Hide()
  27. end
  28. end
  29. end
  30.  
  31. topmenu:SetScript("OnEvent", function(self, event, ...)
  32. topmenudisplay()
  33. end)
  34.  
  35. local function flip(texture,horizontal)
  36.     local ULx,ULy,LLx,LLy,URx,URy,LRx,LRy = texture:GetTexCoord()
  37.     if horizontal then
  38.         texture:SetTexCoord(URx, URy, LRx, LRy, ULx, ULy, LLx, LLy)
  39.     else
  40.         texture:SetTexCoord(LLx, LLy,ULx, ULy, LRx, LRy, URx, URy)
  41.     end
  42. end
  43.  
  44. topmenu:SetScript("OnShow", function(self)
  45.   self:SetScript("OnShow", nil)
  46.   PetBattleFrame:HookScript("OnShow",function() self:Hide() end)
  47.   PetBattleFrame:HookScript("OnHide",function() self:Show() end)
  48.  
  49.   local tmdisplay = self:CreateTexture(nil, "BACKGROUND")
  50.     tmdisplay:SetSize(500, 36)
  51.     tmdisplay:SetPoint("TOP", UIParent, "TOP",0 ,3)
  52.     tmdisplay:SetPoint("CENTER", UIParent, "CENTER")
  53.     tmdisplay:SetTexture(MEDIAPATH .. "topmenu")
  54.     tmdisplay:SetVertexColor(0, 0, 0, .5)
  55.     flip(tmdisplay,false)
  56.    
  57. end)
  58.  
  59. topmenuborder:SetScript("OnShow", function(self)
  60.  
  61.   PetBattleFrame:HookScript("OnShow",function() self:Hide() end)
  62.   PetBattleFrame:HookScript("OnHide",function() self:Show() end)
  63.  
  64.   local tmborderdisplay = self:CreateTexture(nil, "BORDER")
  65.     tmborderdisplay:SetSize(502, 46)
  66.     tmborderdisplay:SetPoint("TOP", UIParent, "TOP", 0, 10)
  67.     tmborderdisplay:SetPoint("CENTER", UIParent, "CENTER")
  68.     tmborderdisplay:SetTexture(MEDIAPATH .. "topmenuborder")
  69.     tmborderdisplay:SetVertexColor(classcolor.r, classcolor.g, classcolor.b, 1.0)
  70.     flip(tmborderdisplay,false)
  71.     topmenuborder:HookScript("OnEvent", function(self, event)
  72.     if event == "PLAYER_REGEN_DISABLED" then
  73.     tmborderdisplay:SetVertexColor(1, 0, 0)
  74.     elseif event == "PLAYER_REGEN_ENABLED" then
  75.     tmborderdisplay:SetVertexColor(classcolor.r, classcolor.g, classcolor.b, 1.0)
  76. end
  77. end)
  78. end)
  79.  
  80. SlashCmdList.TOPMENUSHOW = function()
  81.     TopmenuShow = 1
  82.     ReloadUI()
  83. end
  84. SLASH_TOPMENUSHOW1 = "/tmshow"
  85.  
  86. SlashCmdList.TOPMENUHIDE = function()
  87.     TopmenuShow = nil
  88.     ReloadUI()
  89. end
  90. SLASH_TOPMENUHIDE1 = "/tmhide"

Last edited by almty1 : 09-05-13 at 11:27 AM. Reason: typo
  Reply With Quote