So I tried eePanels2 to see if I could set a panel to only show in combat. I know that this is probably the world's simplest thing to do but eePanels2 made it easy to try out because now I only needed to figure out the actual show/hide-part instead of trying to build a whole addon. :p
I basically just grabbed the events that sounded right from WoWWiki (that's how much I know really...) and modified the "template" in eePanels2 thread but I do have a problem of the panel showing up when I first login or reload my UI (when I'm out of combat). The toggling works fine after the first time I engage in combat. How could I change that?
this is what I pulled together:
function eePanels2:InCombat()
if (UnitAffectingCombat("player")==1) then
THIS:Show()
else
THIS:Hide()
end
end
eePanels2:RegisterEvent("PLAYER_REGEN_DISABLED", eePanels2.InCombat)
eePanels2:RegisterEvent("PLAYER_REGEN_ENABLED", eePanels2.InCombat)
Also it seems to work with just function eePanels2:InCombat() so what does the (self, event, ...) part in the original code actually do and in which cases is it needed?
function eePanels2:InCombat(self, event, ...)
...
I didn't know if I should put this message to The Classroom section or to eePanels2 thread, sorry about that.
THIS:Hide()
-- Hide panel ooc
function eePanels2:PLAYER_REGEN_DISABLED()
THIS:Hide()
end
-- Hide panel ic
function eePanels2:PLAYER_REGEN_ENABLED()
THIS:Show()
end
-- Ace2 event listeners; can't do this in more than one script
eePanels2:RegisterEvent("PLAYER_REGEN_DISABLED")
eePanels2:RegisterEvent("PLAYER_REGEN_ENABLED")
THIS:Hide()
-- Hide panel ooc
function eePanels2:PLAYER_REGEN_DISABLED()
THIS:Hide()
end
-- Hide panel ic
function eePanels2:PLAYER_REGEN_ENABLED()
THIS:Show()
end
-- Ace2 event listeners; can't do this in more than one script
eePanels2:RegisterEvent("PLAYER_REGEN_DISABLED")
eePanels2:RegisterEvent("PLAYER_REGEN_ENABLED")
Should work, not certain though :P.
Yeah though your disabled&enabled were the other way around.
THIS:Hide()
-- Hide panel ooc
function eePanels2:PLAYER_REGEN_ENABLED()
THIS:Hide()
end
-- Show panel ic
function eePanels2:PLAYER_REGEN_DISABLED()
THIS:Show()
end
Just another question that would be nice to sort out: Is the code provided by JRCC basically much better than using the UnitAffectingCombat-thingy? I couldn't really figure out if I could use the UnitAffectingCombat rule somehow without registering those events (because they don't seem related in any other way), so the only thing I deduced was that I needed to register something as the event InCombat to get the function eePanels2:InCombat part to work... I'm bad at explaining things. I like logical sentences. If, then, else ftw.
eePanel1:Hide()
function eePanels2:InCombat()
if (UnitAffectingCombat("player")==1) then
eePanel1:Show()
else
eePanel1:Hide()
end
end
eePanels2:RegisterEvent("PLAYER_REGEN_DISABLED", eePanels2.InCombat)
eePanels2:RegisterEvent("PLAYER_REGEN_ENABLED", eePanels2.InCombat)
vs.
THIS:Hide()
function eePanels2:PLAYER_REGEN_ENABLED()
THIS:Hide()
end
function eePanels2:PLAYER_REGEN_DISABLED()
THIS:Show()
end
eePanels2:RegisterEvent("PLAYER_REGEN_DISABLED")
eePanels2:RegisterEvent("PLAYER_REGEN_ENABLED")
I basically just grabbed the events that sounded right from WoWWiki (that's how much I know really...) and modified the "template" in eePanels2 thread but I do have a problem of the panel showing up when I first login or reload my UI (when I'm out of combat). The toggling works fine after the first time I engage in combat. How could I change that?
this is what I pulled together:
Also it seems to work with just function eePanels2:InCombat() so what does the (self, event, ...) part in the original code actually do and in which cases is it needed?
I didn't know if I should put this message to The Classroom section or to eePanels2 thread, sorry about that.
Should work, not certain though :P.
Yeah though your disabled&enabled were the other way around.
Thanks:)
vs.
call back is optional, if in your namespace (eePanels2) has the event as a :EVENT() then it's implied
the only real differnance is that the first method uses one function and the 2nd uses 2 functions.
Thank you. :)