X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/20f8c5a874b5813a9cc639babb497c048e556e66..9c6a1a5fd7c84ac89e7533839af0f8851edf709f:/OmaTMW/Healthstone.lua diff --git a/OmaTMW/Healthstone.lua b/OmaTMW/Healthstone.lua index 7a8398f..548d1ed 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,12 +19,10 @@ 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(); @@ -31,9 +30,5 @@ local function healthstone() 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);