Files
wow-weakauras/NewAge/CataAuraBar/INIT.lua
2021-12-31 12:01:02 +01:00

98 lines
2.8 KiB
Lua

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