From: Aleksi Blinnikka Date: Fri, 16 Feb 2018 04:06:33 +0000 (+0200) Subject: Add healthstone warning X-Git-Url: https://www.aleksib.fi/git/wowui.git/commitdiff_plain/b2fb545181d1a83904ba470e77e30b31280d1de3?ds=sidebyside Add healthstone warning --- diff --git a/OmaAB/Healthstone.lua b/OmaAB/Healthstone.lua new file mode 100644 index 0000000..7a8398f --- /dev/null +++ b/OmaAB/Healthstone.lua @@ -0,0 +1,39 @@ +-- Healthstone.lua +local _; +local frame = CreateFrame("Frame", "OmaHStone", UIParent); +local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax; + +local function healthstone() + frame:SetPoint("TOP"); + frame:SetWidth(110); + frame:SetHeight(110); + frame.base = frame:CreateTexture(nil, "BACKGROUND"); + frame.base:SetAllPoints(); + frame.base:SetColorTexture(0, 0, 0, 0.5); + frame.stone = frame:CreateTexture(nil, "BORDER"); + frame.stone:SetPoint("TOPLEFT", frame.base, "TOPLEFT", 1, -1); + frame.stone:SetPoint("BOTTOMRIGHT", frame.base, "BOTTOMRIGHT", -1, 1); + frame.stone:SetTexCoord(0.07, 0.93, 0.07, 0.93); + frame.stone:SetTexture(538745); -- "Interface\\ICONS\\Warlock_ 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 + end + end); + frame:UnregisterAllEvents(); + frame:RegisterUnitEvent("UNIT_HEALTH", "player"); + frame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", "player"); +end + +frame:RegisterEvent("PLAYER_LOGIN"); +frame:SetScript("OnEvent", function(self, event) + if event == "PLAYER_LOGIN" then + return healthstone(); + end +end); diff --git a/OmaAB/OmaAB.toc b/OmaAB/OmaAB.toc index fb69886..82c89ed 100644 --- a/OmaAB/OmaAB.toc +++ b/OmaAB/OmaAB.toc @@ -6,5 +6,6 @@ Bindings.xml ExpBar.lua +Healthstone.lua TellMeWhen.lua ActionBars.lua