View Single Post
09-30-16, 04:00 PM   #9
luanoob
A Murloc Raider
Join Date: Sep 2016
Posts: 4
Originally Posted by SDPhantom View Post
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:
  1. textFrame:RegisterEvent("UNIT_AURA")
  2.  textFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
  3.  textFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
  4.  textFrame:SetScript("OnEvent", function(self, event, ...)
  5.  
  6.         local combatcheck = "false"
  7.         local count = 0
  8.  
  9.     if event=="PLAYER_REGEN_DISABLED" then
  10.             combatcheck = "true"
  11.         elseif event =="PLAYER_REGEN_ENABLED" then
  12.             combatcheck = "false"
  13.         end
  14.  
  15.             if (unit and unit ~= "player") then
  16.                  return
  17.             end
  18.  
  19.              --  Check player buffs against the roll the bones buffs
  20.                 for buff in pairs(buffs) do
  21.                         if UnitBuff("player", buff) then
  22.                             count = count + 1
  23.                         end
  24.                 end
  25.  
  26.              --  Give warning if need to reroll the bones
  27.              if combatcheck == "false" then
  28.                   textFrame:message("")
  29.                 elseif combatcheck == "true" and UnitBuff("player", "True Bearing") or UnitBuff("player", "Shark Infested Waters") or count >= 2 then
  30.                      textFrame:message("")
  31.                  else
  32.                      textFrame:message("REROLL THE BONES!!".." "..combatcheck)
  33.                 end
  34.  
  35.  end)
  Reply With Quote