Originally Posted by SDPhantom
If you react to PLAYER_REGEN_DISABLED and PLAYER_REGEN_ENABLED events, they fire when you enter or leave combat respectively.
PS: Don't ever run select(1,...), you're wasting CPU time on a call that does absolutely nothing.
|
Hey
So i have tried a couple of variants with PLAYER_REGEN_DISABLED\ENABLED. But i cant get the text to show at all when i try to tell it to not show it for out of combat, it wont show in combat either.
Would be really cool if someone could help me with how i should be testing with this event to do it properly.
One example i tried that didn't work:
Lua Code:
textFrame:RegisterEvent("UNIT_AURA")
textFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
textFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
textFrame:SetScript("OnEvent", function(self, event, ...)
local combatcheck = "false"
local count = 0
if event=="PLAYER_REGEN_DISABLED" then
combatcheck = "true"
elseif event =="PLAYER_REGEN_ENABLED" then
combatcheck = "false"
end
if (unit and unit ~= "player") then
return
end
-- Check player buffs against the roll the bones buffs
for buff in pairs(buffs) do
if UnitBuff("player", buff) then
count = count + 1
end
end
-- Give warning if need to reroll the bones
if combatcheck == "false" then
textFrame:message("")
elseif combatcheck == "true" and UnitBuff("player", "True Bearing") or UnitBuff("player", "Shark Infested Waters") or count >= 2 then
textFrame:message("")
else
textFrame:message("REROLL THE BONES!!".." "..combatcheck)
end
end)