b069259 - Add new raids to auto-logging
[wowui.git] / OmaTMW / Healthstone.lua
1 -- Healthstone.lua
2 local _;
3 local frame = CreateFrame("Frame", "OmaHStone", UIParent);
4 local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax;
5 local UnitIsDeadOrGhost = UnitIsDeadOrGhost;
6
7 local function healthstone()
8     frame:SetPoint("TOP");
9     frame:SetWidth(110);
10     frame:SetHeight(110);
11     frame.base = frame:CreateTexture(nil, "BACKGROUND");
12     frame.base:SetAllPoints();
13     frame.base:SetColorTexture(0, 0, 0, 0.5);
14     frame.stone = frame:CreateTexture(nil, "BORDER");
15     frame.stone:SetPoint("TOPLEFT", frame.base, "TOPLEFT", 1, -1);
16     frame.stone:SetPoint("BOTTOMRIGHT", frame.base, "BOTTOMRIGHT", -1, 1);
17     frame.stone:SetTexCoord(0.07, 0.93, 0.07, 0.93);
18     frame.stone:SetTexture(538745); -- "Interface\\ICONS\\Warlock_ Healthstone"
19     frame:Hide();
20
21     frame:SetScript("OnEvent", function(self, event)
22         if not UnitIsDeadOrGhost("player") and UnitHealth("player")/UnitHealthMax("player") < 0.3 then
23             frame:Show();
24         else
25             frame:Hide();
26         end
27     end);
28     frame:UnregisterAllEvents();
29     frame:RegisterUnitEvent("UNIT_HEALTH", "player");
30     frame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", "player");
31 end
32
33 frame:SetScript("OnEvent", healthstone);
34 frame:RegisterEvent("PLAYER_LOGIN");