Rework stinky detector to be a little more simple and a lot more functional
This commit is contained in:
@@ -1,18 +1,44 @@
|
||||
-- TICKER_100
|
||||
function()
|
||||
---@type Message
|
||||
local message = aura_env.messageQueue[1]
|
||||
if message == nil then return end
|
||||
|
||||
table.remove(aura_env.messageQueue, 1)
|
||||
if aura_env.config.debug then
|
||||
print(string.format("Processing message; %d in queue", #aura_env.messageQueue))
|
||||
DevTools_Dump(message)
|
||||
-- TICKER_1000
|
||||
---@param allstates allstates
|
||||
---@param e string
|
||||
---@param prefix string
|
||||
---@param msg string
|
||||
function(allstates, e, prefix, msg, ...)
|
||||
for i = 1, 40 do
|
||||
if UnitIsPlayer("nameplate" .. i) then
|
||||
local name = UnitName("nameplate" .. i)
|
||||
if aura_env.stinkies[name] then
|
||||
aura_env.StinkyDetected(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if message.addon then
|
||||
SendAddonMessage(aura_env.addonprefix, message.message, message.channel, message.to)
|
||||
else
|
||||
SendChatMessage(message.message, message.channel, nil, message.to)
|
||||
local ttl = aura_env.config.ttl or 10
|
||||
for stinky, data in pairs(aura_env.detectedStinkies) do
|
||||
local elapsed = GetTime() - data.seen
|
||||
if allstates[stinky] then
|
||||
if elapsed > ttl then
|
||||
allstates[stinky].show = false
|
||||
allstates[stinky].changed = true
|
||||
aura_env.detectedStinkies[stinky] = nil
|
||||
else
|
||||
allstates[stinky].progress = string.format("%20s", elapsed)
|
||||
allstates[stinky].changed = true
|
||||
end
|
||||
else
|
||||
allstates[stinky] = {
|
||||
show = true,
|
||||
changed = true,
|
||||
name = string.format("%-20s", stinky),
|
||||
progressType = "timed",
|
||||
duration = ttl,
|
||||
expirationTime = GetTime() + ttl,
|
||||
autohide = true,
|
||||
index = GetTime(),
|
||||
progress = string.format("%20s", elapsed)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user