Counterder = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceHook-2.0")
local Glib = AceLibrary("Gratuity-2.0")
function Counterder:OnEnable()
self:Hook("ActionButton_UpdateCount","UpdateCount")
end
function Counterder:UpdateCount()
self.hooks["ActionButton_UpdateCount"].orig()
local text = getglobal(this:GetName().."Count")
if(text:GetText() == nil and not IsConsumableAction(ActionButton_GetPagedID(this)) ) then
text:SetText(self:GetCount())
end
end
function Counterder:GetCount()
local Cost
local PowerType = UnitPowerType("player")
local PowerAmount = UnitMana("player")
Glib:SetAction(ActionButton_GetPagedID(this))
if(Glib:Find("Energy") and PowerType == 3)then
_,_,Cost = Glib:Find("(%S+) Energy")
return floor(PowerAmount/Cost)
elseif(Glib:Find("Mana") and PowerType == 0)then
_,_,Cost = Glib:Find("(%S+) Mana")
return floor(PowerAmount/Cost)
elseif(Glib:Find("Rage") and PowerType == 1)then
_,_,Cost = Glib:Find("(%S+) Rage")
return floor(PowerAmount/Cost)
else
return
end
end