View Single Post
Unread 02-25-13, 09:56 PM   #2
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,260
This should work for SexyCooldown, and any other frames you want to hide or show only in or out of combat. Type "/fstack" and move the cursor over the SexyCooldown bar to check its name; if it's not "SexyCooldown", change the code below accordingly. Type "/fstack" again to hide the frame stack tooltip.

Code:
-- Add frames to hide in this table:
local FramesToHide = {
	["SexyCooldown"] = "PLAYER_REGEN_ENABLED", -- Show out of combat
	["SomeOtherFrame"] = "PLAYER_REGEN_DISABLED", -- Show in combat
}

local CombatHider = CreateFrame("Frame")
CombatHider:RegisterEvent("PLAYER_REGEN_DISABLED")
CombatHider:RegisterEvent("PLAYER_REGEN_ENABLED")
CombatHider:SetScript("OnEvent", function(self, event)
	for frameName, showEvent in pairs(FramesToHide) do
		local frame = _G[frameName]
		if frame then
			frame:SetShown(event == showEvent)
		end
	end
end)
If you need help turning the above code into an addon, paste it onto this page, enter a title, and click the green button: http://addon.ziuo.net/
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!

Last edited by Phanx : 02-26-13 at 04:47 PM.
Phanx is offline   Reply With Quote