Originally Posted by
Calabera
I will look at this later, right now I am too drunk to think straight.
Indeed.
Code:
-- config
local r, g, b = 1,1,1 -- rgb colors in a 0-1 range
local x, y = 0, 0 -- horizontal/vertical offset from the bottom left corner
-- code
local statusbar = CreateFrame("Frame", nil, UIParent)
statusbar:SetPoint("BOTTOMLEFT", x, (y+2.5))
statusbar:SetSize(70, 10)
statusbar.foreground = statusbar:CreateTexture(nil, "ARTWORK")
statusbar.foreground:SetPoint("TOPLEFT",15,0)
statusbar.foreground:SetPoint("BOTTOMLEFT",15,0)
statusbar.foreground:SetTexture(r,g,b)
statusbar.background = statusbar:CreateTexture(nil, "BACKGROUND")
statusbar.background:SetPoint("TOPLEFT", 15, 0)
statusbar.background:SetPoint("BOTTOMRIGHT")
statusbar.background:SetTexture(r*0.6,g*0.6,b*0.6)
statusbar.icon = statusbar:CreateTexture(nil, "OVERLAY")
statusbar.icon:SetSize(15,15)
statusbar.icon:SetTexture("Interface\\Icons\\spell_nature_naturesblessing")
statusbar.icon:SetPoint("LEFT")
function statusbar:SetValues(cur, max)
if cur == 0 then
self.foreground:Hide()
else
self.foreground:Show()
self.foreground:SetWidth(55*(cur/max))
end
end
statusbar:Hide()
local updateframe = CreateFrame("Frame")
updateframe:SetScript("OnEvent", function(self, event, ...)
local arg={...}
self.pguid = self.pguid or UnitGUID("player")
if (arg[2] == "SPELL_AURA_APPLIED") and (arg[6] == self.pguid) and (arg[10] == "Nature's Grace") then
self.lastApplied = GetTime()
end
end)
updateframe:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
updateframe:SetScript("OnUpdate", function(self)
if not self.lastApplied then
statusbar:Hide()
return
end
local timeSince = GetTime()-self.lastApplied
if timeSince > 60 then
statusbar:Hide()
else
statusbar:Show()
statusbar:SetValues(60-timeSince, 60)
end
end)
How to use. Untested. Report back with issues.