View Single Post
09-30-16, 05:23 PM   #11
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
Hey.

The reason why it's not working is because you made your "combatcheck" local inside the onevent function. So every time the UNIT_AURA event fires, combatcheck will be false. Also, there a boolean data type you can use instead of string. (true/false without the quotation mark)

Try this:
Lua Code:
  1. local combatcheck = false
  2.  
  3. textFrame:RegisterUnitEvent("UNIT_AURA", "player")
  4. textFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
  5. textFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
  6. textFrame:SetScript("OnEvent", function(self, event, ...)
  7.  
  8.     if event=="PLAYER_REGEN_DISABLED" then
  9.         combatcheck = true
  10.  
  11.     elseif event =="PLAYER_REGEN_ENABLED" then
  12.         combatcheck = false
  13.     end
  14.  
  15.     local count = 0
  16.     for buff in pairs(buffs) do
  17.         if UnitBuff("player", buff) then
  18.             count = count + 1
  19.         end
  20.     end
  21.  
  22.     --  Give warning if need to reroll the bones
  23.     if not combatcheck then
  24.         textFrame:message("")
  25.     elseif UnitBuff("player", "True Bearing") or UnitBuff("player", "Shark Infested Waters") or count >= 2 then
  26.         textFrame:message("")
  27.     else
  28.         textFrame:message("REROLL THE BONES!!".." "..tostring(combatcheck))
  29.     end
  30. end)

Last edited by sticklord : 09-30-16 at 05:25 PM.
  Reply With Quote