b2fb545 - Add healthstone warning
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Fri, 16 Feb 2018 04:06:33 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Fri, 16 Feb 2018 04:06:33 +0000
OmaAB/Healthstone.lua [new file with mode: 0644]
OmaAB/OmaAB.toc

diff --git a/OmaAB/Healthstone.lua b/OmaAB/Healthstone.lua
new file mode 100644 (file)
index 0000000..7a8398f
--- /dev/null
@@ -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);
index fb69886..82c89ed 100644 (file)
@@ -6,5 +6,6 @@
 
 Bindings.xml
 ExpBar.lua
+Healthstone.lua
 TellMeWhen.lua
 ActionBars.lua