Add dynamic aura tracker
This commit is contained in:
98
NewAge/CataAuraBar/INIT.lua
Normal file
98
NewAge/CataAuraBar/INIT.lua
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
local Aura = {
|
||||||
|
New = function(self, spellName, index)
|
||||||
|
o = {
|
||||||
|
["name"] = spellName,
|
||||||
|
["index"] = index or 1,
|
||||||
|
}
|
||||||
|
setmetatable(o, self)
|
||||||
|
self.__index = self
|
||||||
|
return o
|
||||||
|
end,
|
||||||
|
IsActive = function(self)
|
||||||
|
aura = self:GetAuraName()
|
||||||
|
print(UnitAura("player", aura))
|
||||||
|
return UnitAura("player", aura) ~= nil
|
||||||
|
end,
|
||||||
|
IsOnCooldown = function(self)
|
||||||
|
return GetSpellCooldown(self.name) > 0
|
||||||
|
end,
|
||||||
|
GetAuraName = function(self)
|
||||||
|
aura = self.aura
|
||||||
|
if aura == nil then
|
||||||
|
aura = self.name
|
||||||
|
end
|
||||||
|
return aura
|
||||||
|
end,
|
||||||
|
AddAsAura = function(self, allstates)
|
||||||
|
aura = self:GetAuraName()
|
||||||
|
duration = select(6, UnitAura("player", aura))
|
||||||
|
expirationTime = select(7, UnitAura("player", aura))
|
||||||
|
icon = self:GetAuraIcon()
|
||||||
|
allstates[self.name] = {
|
||||||
|
changed = true,
|
||||||
|
show = true,
|
||||||
|
resort = true,
|
||||||
|
progressType = "timed",
|
||||||
|
duration = duration,
|
||||||
|
expirationTime = expirationTime,
|
||||||
|
index = self.index,
|
||||||
|
icon = icon,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
AddAsCooldown = function(self, allstates)
|
||||||
|
startTime, duration = GetSpellCooldown(self.name)
|
||||||
|
icon = self:GetSpellIcon()
|
||||||
|
allstates[self.name] = {
|
||||||
|
changed = true,
|
||||||
|
show = true,
|
||||||
|
resort = true,
|
||||||
|
progressType = "timed",
|
||||||
|
duration = duration,
|
||||||
|
expirationTime = startTime + duration,
|
||||||
|
index = self.index,
|
||||||
|
icon = icon,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
AddAsIcon = function(self, allstates)
|
||||||
|
icon = self:GetSpellIcon()
|
||||||
|
allstates[self.name] = {
|
||||||
|
changed = true,
|
||||||
|
show = true,
|
||||||
|
resort = true,
|
||||||
|
progressType = "static",
|
||||||
|
value = 1,
|
||||||
|
total = 1,
|
||||||
|
index = self.index,
|
||||||
|
icon = icon,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
GetSpellIcon = function(self)
|
||||||
|
return select(3, GetSpellInfo(self.name))
|
||||||
|
end,
|
||||||
|
GetAuraIcon = function(self)
|
||||||
|
aura = self:GetAuraName()
|
||||||
|
spellID = select(11, UnitAura("player", aura))
|
||||||
|
return select(3, GetSpellInfo(spellID))
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
aura_env.auras = {}
|
||||||
|
for name in string.gmatch(aura_env.config.spellList, "([a-zA-Z ]+)") do
|
||||||
|
name = name:gsub("^[ ]+", "")
|
||||||
|
name = name:gsub("\n$", "")
|
||||||
|
name = name:gsub("[ ]+$", "")
|
||||||
|
auraObj = Aura:New(name, #aura_env.auras + 1)
|
||||||
|
aura_env.auras[#aura_env.auras + 1] = auraObj
|
||||||
|
end
|
||||||
|
|
||||||
|
aura_env.HandleEvent = function(allstates)
|
||||||
|
for k, v in ipairs(aura_env.auras) do
|
||||||
|
if v:IsActive() then
|
||||||
|
v:AddAsAura(allstates)
|
||||||
|
elseif v:IsOnCooldown() and not v:IsActive() then
|
||||||
|
v:AddAsCooldown(allstates)
|
||||||
|
elseif not v:IsOnCooldown() and not v:IsActive() then
|
||||||
|
v:AddAsIcon(allstates)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
11
NewAge/CataAuraBar/README.md
Normal file
11
NewAge/CataAuraBar/README.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
## While aura is active show aura
|
||||||
|
|
||||||
|
## While aura is inactive and off cooldown show icon
|
||||||
|
|
||||||
|
## While aura is inactive and on cooldown show cooldown
|
||||||
|
|
||||||
|
## Use tsu
|
||||||
|
|
||||||
|
### ACTIONBAR_UPDATE_COOLDOWN when anything on bar goes on cooldown
|
||||||
|
|
||||||
|
### UNIT_AURA with one argument which is unit when aura fades/gets applied
|
||||||
12
NewAge/CataAuraBar/TSU.lua
Normal file
12
NewAge/CataAuraBar/TSU.lua
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
function(allstates, e, ...)
|
||||||
|
for _,v in pairs(allstates) do
|
||||||
|
v.show = false
|
||||||
|
v.changed = true
|
||||||
|
end
|
||||||
|
|
||||||
|
aura_env.HandleEvent(allstates)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- /run WeakAuras.ScanEvents("SPELL_UPDATE_COOLDOWN")
|
||||||
|
-- /dump UnitAura("player", "Blessing of Might")
|
||||||
Reference in New Issue
Block a user