Code format

This commit is contained in:
2025-05-15 21:19:10 +02:00
parent 4220b4d0bd
commit 635147c29b
7 changed files with 141 additions and 168 deletions

View File

@@ -1,30 +1,23 @@
local function getItemLink(container, slot) local function getItemLink(container, slot) return select(7, GetContainerItemInfo(container, slot)) or "" end
return select(7, GetContainerItemInfo(container, slot)) or "" local function getBindType(container, slot) return select(14, GetItemInfo(getItemLink(container, slot))) or 0 end
end local function isBoe(container, slot) return getBindType(container, slot) == 1 end
local function getBindType(container, slot)
return select(14, GetItemInfo(getItemLink(container, slot))) or 0
end
local function isBoe(container, slot)
return getBindType(container, slot) == 1
end
local showGlow = function(container, slot) local showGlow = function(container, slot)
ActionButton_ShowOverlayGlow(_G["ElvUI_ContainerFrameBag" .. container .. "Slot" .. slot]) ActionButton_ShowOverlayGlow(_G["ElvUI_ContainerFrameBag" .. container .. "Slot" .. slot])
end end
local hideGlow = function(container, slot) local hideGlow = function(container, slot)
ActionButton_HideOverlayGlow(_G["ElvUI_ContainerFrameBag" .. container .. "Slot" .. slot]) ActionButton_HideOverlayGlow(_G["ElvUI_ContainerFrameBag" .. container .. "Slot" .. slot])
end end
aura_env.update = function() aura_env.update = function()
for container = 0, 4 do for container = 0, 4 do
for slot = 1, GetContainerNumSlots(container) do for slot = 1, GetContainerNumSlots(container) do
print(C_Item.IsBound(ItemLocation:CreateFromBagAndSlot(container, slot))) print(C_Item.IsBound(ItemLocation:CreateFromBagAndSlot(container, slot)))
if isBoe(container, slot) then if isBoe(container, slot) then
showGlow(container, slot) showGlow(container, slot)
else else
hideGlow(container, slot) hideGlow(container, slot)
end end
end end
end end
end end

View File

@@ -8,16 +8,12 @@ local CooldownType = {
} }
local NullType = CooldownType:New() local NullType = CooldownType:New()
NullType.GetActiveInfo = function(self) NullType.GetActiveInfo = function(self) return false, 0, 0 end
return false, 0, 0
end
local TotemType = CooldownType:New() local TotemType = CooldownType:New()
TotemType.GetActiveInfo = function(self) TotemType.GetActiveInfo = function(self)
for i = 1, 4 do for i = 1, 4 do
local present, name, start, duration = GetTotemInfo(i) local present, name, start, duration = GetTotemInfo(i)
if present and name == self.name then if present and name == self.name then return true, start, duration end
return true, start, duration
end
end end
return false, 0, 0 return false, 0, 0
end end
@@ -41,9 +37,7 @@ local Cooldown = {
return start > 0 and duration > aura_env.gcdThreshold, start, duration return start > 0 and duration > aura_env.gcdThreshold, start, duration
end, end,
GetActiveInfo = function(self) GetActiveInfo = function(self) return self.type:GetActiveInfo() end,
return self.type:GetActiveInfo()
end
} }
aura_env.cooldowns = { aura_env.cooldowns = {

View File

@@ -1,73 +1,72 @@
aura_env.trackedSpells = { aura_env.trackedSpells = {
20271, -- Judgement 20271, -- Judgement
26573, -- Consecration 26573, -- Consecration
209202, -- Eye of Tyr 209202, -- Eye of Tyr
213652, -- Hand of the Protector 213652, -- Hand of the Protector
31935, -- Avenger's Shield 31935, -- Avenger's Shield
53600, -- Shield of the Righteous 53600, -- Shield of the Righteous
1044, -- Hand of Freedom 1044, -- Hand of Freedom
155145, -- Arcane Torrent 155145, -- Arcane Torrent
853, -- Hammer of Justice 853, -- Hammer of Justice
6940, -- Hand of Sacrifice 6940, -- Hand of Sacrifice
31850, -- Ardent Defender 31850, -- Ardent Defender
86659, -- Guardian of Ancient Kings 86659, -- Guardian of Ancient Kings
204018, -- Blessing of Spellwarding 204018, -- Blessing of Spellwarding
-- --
108416, -- Dark Pact 108416, -- Dark Pact
196447, -- Channel Demonfire 196447, -- Channel Demonfire
104773, -- Unending Resolve 104773, -- Unending Resolve
196586, -- Dimensional Rift 196586, -- Dimensional Rift
} }
local iconDisplayDuration = 0.4 local iconDisplayDuration = 0.4
local gcdDuration = 1.5 local gcdDuration = 1.5
aura_env.cache = {} aura_env.cache = {}
for k, spellId in pairs(aura_env.trackedSpells) do for k, spellId in pairs(aura_env.trackedSpells) do
aura_env.cache[spellId] = { aura_env.cache[spellId] = {
ready = true, ready = true,
hasCharges = false, hasCharges = false,
} }
if GetSpellCharges(spellId) then if GetSpellCharges(spellId) then
aura_env.cache[spellId].hasCharges = true aura_env.cache[spellId].hasCharges = true
aura_env.cache[spellId].charges = select(1, GetSpellCharges(spellId)) aura_env.cache[spellId].charges = select(1, GetSpellCharges(spellId))
end end
end end
aura_env.processEvent = function(allstates) aura_env.processEvent = function(allstates)
for k, spellId in pairs(aura_env.trackedSpells) do for k, spellId in pairs(aura_env.trackedSpells) do
-- Handle spells with charges -- Handle spells with charges
local isReady local isReady
if (aura_env.cache[spellId].hasCharges) then if aura_env.cache[spellId].hasCharges then
local charges = select(1, GetSpellCharges(spellId)) local charges = select(1, GetSpellCharges(spellId))
if (charges > aura_env.cache[spellId].charges) then if charges > aura_env.cache[spellId].charges then
isReady = true isReady = true
aura_env.cache[spellId].charges = charges aura_env.cache[spellId].charges = charges
else else
isReady = false isReady = false
aura_env.cache[spellId].charges = charges aura_env.cache[spellId].charges = charges
end end
else else
isReady = select(2, GetSpellCooldown(spellId)) < gcdDuration isReady = select(2, GetSpellCooldown(spellId)) < gcdDuration
end end
if not aura_env.cache[spellId].ready and isReady then
local icon = select(3, GetSpellInfo(spellId))
allstates[spellId] = {
show = true,
changed = true,
index = GetTime(),
resort = true,
if (not aura_env.cache[spellId].ready and isReady) then icon = icon,
local icon = select(3, GetSpellInfo(spellId))
allstates[spellId] = {
show = true,
changed = true,
index = GetTime(),
resort = true,
icon = icon, progressType = "timed",
expirationTime = GetTime() + iconDisplayDuration,
duration = iconDisplayDuration,
autoHide = true,
}
end
progressType = "timed", aura_env.cache[spellId].ready = isReady
expirationTime = GetTime() + iconDisplayDuration, end
duration = iconDisplayDuration, end
autoHide = true,
}
end
aura_env.cache[spellId].ready = isReady
end
end

View File

@@ -7,9 +7,7 @@ for _, group in ipairs(groups) do
local playerFrames = { playerFrame1, playerFrame2, playerFrame3, playerFrame4, playerFrame5 } local playerFrames = { playerFrame1, playerFrame2, playerFrame3, playerFrame4, playerFrame5 }
for _, player in ipairs(playerFrames) do for _, player in ipairs(playerFrames) do
if player.Name:IsVisible() then if player.Name:IsVisible() then aura_env.players[#aura_env.players + 1] = player end
aura_env.players[#aura_env.players + 1] = player
end
end end
end end

View File

@@ -3,88 +3,81 @@ if not WeakAurasSaved.Cyka.Cache then WeakAurasSaved.Cyka.Cache = {} end
if not WeakAurasSaved.Cyka.Cache.PlayerInfo then WeakAurasSaved.Cyka.Cache.PlayerInfo = {} end if not WeakAurasSaved.Cyka.Cache.PlayerInfo then WeakAurasSaved.Cyka.Cache.PlayerInfo = {} end
local allianceRaces = { local allianceRaces = {
"Draenai", "Draenai",
"Dwarf", "Dwarf",
"Gnome", "Gnome",
"Human", "Human",
"Night Elf", "Night Elf",
"Worgen" "Worgen",
} }
PlayerController = { PlayerController = {
nearbyPlayers = {}, nearbyPlayers = {},
addPlayer = function(self, name) addPlayer = function(self, name) self.nearbyPlayers[name] = Player:New(name) end,
self.nearbyPlayers[name] = Player:New(name) getPlayers = function(self) end,
end, process = function(guid)
getPlayers = function(self) if self.nearbyPlayers[guid] == nil then
self.addPlayer(guid)
end, else
process = function(guid) end
if (self.nearbyPlayers[guid] == nil) then end,
self.addPlayer(guid)
else
end
end
} }
Player = { Player = {
guid = nil, guid = nil,
lastSighted = nil, lastSighted = nil,
info = nil, info = nil,
update = function(self) update = function(self) self.lastSighted = GetTime() end,
self.lastSighted = GetTime() getFormatted = function(self)
end, -- Color by class
getFormatted = function(self) -- Format time
-- Color by class return info.name .. " " .. self.lastSighted
-- Format time end,
return info.name .. " " .. self.lastSighted
end
} }
PlayerInfo = { PlayerInfo = {
class = nil, class = nil,
race = nil, race = nil,
name = nil, name = nil,
isHostile = nil, isHostile = nil,
} }
function Player:New(guid) function Player:New(guid)
o = {} o = {}
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
o.guid = guid or "" o.guid = guid or ""
o.lastSighted = GetTime() o.lastSighted = GetTime()
o.info = PlayerInfo:New(guid) o.info = PlayerInfo:New(guid)
return o return o
end end
function PlayerInfo:New(guid) function PlayerInfo:New(guid)
o = {} o = {}
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
local info local info
if WeakAurasSaved.Cyka.Cache.PlayerInfo[guid] then if WeakAurasSaved.Cyka.Cache.PlayerInfo[guid] then
info = WeakAurasSaved.Cyka.Cache.PlayerInfo[guid] info = WeakAurasSaved.Cyka.Cache.PlayerInfo[guid]
else else
info = GetPlayerInfoByGUID(guid) info = GetPlayerInfoByGUID(guid)
WeakAurasSaved.Cyka.Cache.PlayerInfo[guid] = { WeakAurasSaved.Cyka.Cache.PlayerInfo[guid] = {
class = info.class, class = info.class,
race = info.race, race = info.race,
name = info.name, name = info.name,
isHostile = allianceRaces[race] ~= nil isHostile = allianceRaces[race] ~= nil,
} }
end end
o.class = info.class or "" o.class = info.class or ""
o.race = info.race or "" o.race = info.race or ""
o.name = info.name or "" o.name = info.name or ""
o.isHostile = info.isHostile or true o.isHostile = info.isHostile or true
return o return o
end end
aura_env.processEvent = function(caster, target) aura_env.processEvent = function(caster, target)
PlayerController:process(caster) PlayerController:process(caster)
PlayerController:process(target) PlayerController:process(target)
end end

View File

@@ -1,5 +1,3 @@
aura_env.getCharges = function() aura_env.getCharges = function() return select(1, GetSpellCharges(53600)) end
return select(1, GetSpellCharges(53600))
end
aura_env.currentCharges = 0 aura_env.currentCharges = 0

View File

@@ -1,8 +1,6 @@
aura_env.findAura = function(LFname) aura_env.findAura = function(LFname)
for i = 1, 40 do for i = 1, 40 do
local name = UnitAura("player", i) local name = UnitAura("player", i)
if (name == LFname) then if name == LFname then return i end
return i end
end end
end
end