Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions modules/power.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,47 @@ local function reset()
end
end

local manaTicker = CreateFrame("Frame")
manaTicker:RegisterEvent("UNIT_MANA") -- Fires when mana changes

local lastMana = UnitMana("player")
local lastManaTickTime = nil
local manaTickInterval = 2.0

manaTicker:SetScript("OnEvent", function(self, event)
local currentMana = UnitMana("player")
if currentMana > lastMana then
lastManaTickTime = GetTime()
end
lastMana = currentMana
end)

local EnergyUpdate = function()
local powerType = UnitPowerType("player")
local frame = this:GetParent()
local time = GetTime()
local Position = 0

if powerType == 0 then

if timestamp then
if (time - timestamp) >= 5 then
timestamp = nil
this:Hide()

if UnitMana("player") == UnitManaMax("player") then
timestamp = nil
lastManaTickTime = nil
this:Hide()
return
elseif lastManaTickTime ~= nil then
-- 2sec mana ticker
Position = ((time - lastManaTickTime) / manaTickInterval)
end
else
-- 5sec rule
Position = ((time - timestamp) / 5)
end
end

elseif powerType == 3 then
if (time - this.startTime) >= 2 then --Ticks happen every 2 sec
this.startTime = GetTime()
Expand Down Expand Up @@ -287,4 +314,4 @@ function Power:SetBarTexture(frame,texture)
frame.powerBar.manaUsage.bar:SetStatusBarTexture("Interface\\Tooltips\\UI-Tooltip-Background")
end
end
end
end