local _;
local frame = CreateFrame("Frame", "OmaHStone", UIParent);
local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax;
+local UnitIsDeadOrGhost = UnitIsDeadOrGhost;
local function healthstone()
frame:SetPoint("TOP");
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);