If you wish to help support this site please disable your adblock program.


Click here to become a Premium Member : No ads site-wide : Forum privileges : Upgraded services : Giveaway & moreSupport the Site! Support Us!
Tukui » Lua Script Help » How to autohide the classbar when out of combat?
  1. Challenger CheneyFM
    offline
    Member
    Posts: 21

    Hey,
    I want to autohide the ArcaneBar when out of combat, so I add the flowing code:

    			if T.myclass == "MAGE" then
    				self.shadow:Point("TOPLEFT", -4, 12)				   
    
    				local mb = CreateFrame("Frame", "TukuiArcaneBar", self)
    				mb:Point("BOTTOMLEFT", self, "TOPLEFT", 0, 1)
    				mb:SetWidth((T.lowversion and 186) or 250)
    				mb:SetHeight(8)
    				mb:SetBackdrop(backdrop)
    				mb:SetBackdropColor(0, 0, 0)
    				mb:SetBackdropBorderColor(0, 0, 0)				
    
    				for i = 1, 6 do
    					mb[i] = CreateFrame("StatusBar", "TukuiArcaneBar"..i, mb)
    					mb[i]:Height(8)
    					mb[i]:SetStatusBarTexture(C.media.normTex)
    
    					if i == 1 then
    						if T.lowversion then
    							mb[i]:Width((186 / 6))
    						else
    							mb[i]:Width((250 / 6) - 2)
    						end
    						mb[i]:SetPoint("LEFT", mb, "LEFT", 0, 0)
    					else
    						if T.lowversion then
    							mb[i]:Width((186 / 6) - 1)
    						else
    							mb[i]:Width((250 / 6 - 1))
    						end
    						mb[i]:SetPoint("LEFT", mb[i-1], "RIGHT", 1, 0)
    					end
    
    					mb[i].bg = mb[i]:CreateTexture(nil, 'ARTWORK')
    				end
    
    				mb:SetScript("OnShow", function(self)
    					local f = self:GetParent()
    					f.shadow:Point("TOPLEFT", -4, 12)
    				end)
    
    				mb:SetScript("OnHide", function(self)
    					local f = self:GetParent()
    					f.shadow:Point("TOPLEFT", -4, 4)
    				end)				
    
                                     --------- I added this part
    				mb:RegisterEvent("PLAYER_REGEN_ENABLED")
    				mb:RegisterEvent("PLAYER_REGEN_DISABLED")
    
    				if event == "PLAYER_REGEN_DISABLED" then
    					mb:Hide()
    				elseif event == "PLAYER_REGEN_ENABLED" then
    					mb:Show()
    				end
                                   ------------------------------
    
    				self.ArcaneChargeBar = mb
    			end
    

    But it doesn't work, I searched everywhere, I hope anyone can help me here.
    Thx a lot.

    Posted 9 months ago - #1

    Permalink



  2. If you wish to help support this site please disable your adblock program.


    Rival Nisha
    offline
    VIP
    Posts: 277
    local function OnEvent(self, event)
    		if event == "PLAYER_ENTERING_WORLD" then
    			mb:Hide()
    			self:UnregisterEvent("PLAYER_ENTERING_WORLD")
    		elseif event == "PLAYER_REGEN_ENABLED" then
    			mb:Hide()
    		elseif event == "PLAYER_REGEN_DISABLED" then
    			mb:Show()
    		end
    	end
    
    local toogleclassbar = CreateFrame("frame", nil)
    toogleclassbar:RegisterEvent("PLAYER_REGEN_ENABLED")
    toogleclassbar:RegisterEvent("PLAYER_REGEN_DISABLED")
    toogleclassbar:RegisterEvent("PLAYER_ENTERING_WORLD")
    toogleclassbar:SetScript("OnEvent", OnEvent)

    This should work!

    Edit: For Hydra!

    Posted 9 months ago - #2

    Permalink

  3. Hero Hydra
    offline
    Overlord
    Posts: 5,606

    why does your function have a random vararg? o.o

    I don't suffer from insanity, I enjoy it.
    Posted 9 months ago - #3

    Permalink

  4. Rival Nisha
    offline
    VIP
    Posts: 277

    Fixed!

    Posted 9 months ago - #4

    Permalink

  5. Challenger CheneyFM
    offline
    Member
    Posts: 21

    wow!!!!
    It works !!!!
    WHY?????
    It's amazing!!!!

    Posted 9 months ago - #5

    Permalink

  6. Challenger CheneyFM
    offline
    Member
    Posts: 21

    Well, there is a little bug
    If I fade out of combat with more then one arcane buffs, when I appear in combat again, the Arcanebar doesn't reset.

    So, I replace the function Show() and Hide() with SetAlpha(), It's be OK.

    Posted 9 months ago - #6

    Permalink

RSS feed for this topic

Reply

You must log in to post.