X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/5d20ef029d0d455efa76ce2479b92d6196eab6ef..52f2ef034b1fad1d0fa815270adee20afd295414:/OmaTMW/Healthstone.lua diff --git a/OmaTMW/Healthstone.lua b/OmaTMW/Healthstone.lua index 7a8398f..bbf8850 100644 --- a/OmaTMW/Healthstone.lua +++ b/OmaTMW/Healthstone.lua @@ -2,6 +2,7 @@ local _; local frame = CreateFrame("Frame", "OmaHStone", UIParent); local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax; +local UnitIsDeadOrGhost = UnitIsDeadOrGhost; local function healthstone() frame:SetPoint("TOP"); @@ -18,22 +19,15 @@ local function healthstone() frame:Hide(); frame:SetScript("OnEvent", function(self, event) - if event == "UNIT_HEALTH" or event == "UNIT_HEALTH_FREQUENT" then - if UnitHealth("player")/UnitHealthMax("player") < 0.3 then - frame:Show(); - else - frame:Hide(); - end + if not UnitIsDeadOrGhost("player") and UnitHealth("player")/UnitHealthMax("player") < 0.3 then + frame:Show(); + else + frame:Hide(); end end); frame:UnregisterAllEvents(); frame:RegisterUnitEvent("UNIT_HEALTH", "player"); - frame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", "player"); end +frame:SetScript("OnEvent", healthstone); frame:RegisterEvent("PLAYER_LOGIN"); -frame:SetScript("OnEvent", function(self, event) - if event == "PLAYER_LOGIN" then - return healthstone(); - end -end);