Code polish

This commit is contained in:
2024-10-14 20:16:34 +02:00
parent faf704dc53
commit 50d5dbe3e0
4 changed files with 23 additions and 16 deletions

View File

@@ -1,6 +1,8 @@
-- COMBAT_LOG_EVENT_UNFILTERED
---@param e string
function(e, ...)
-- /run RegisterAddonMessagePrefix("STINKY_DETECTOR")
-- RegisterAddonMessagePrefix(aura_env.addonprefix)
local detected = false
local stinky = ""

View File

@@ -7,6 +7,7 @@ function()
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)
end
if message.addon then

View File

@@ -86,7 +86,12 @@ function(allstates, e, prefix, msg, ...)
end
local stinky = aura_env.stinkies[name]
if not stinky then return false end
if not stinky then
if aura_env.config.debug then
print(string.format("Could not find stinky for %s", name))
end
return false
end
if not allstates[name] then
PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master")

View File

@@ -1,6 +1,3 @@
-- TODO: Add zone detection and all that shit so we're not always in orgrimmar
-- see GetSubZoneText() and GetZoneText()
---@type Message[]
aura_env.messageQueue = {}
aura_env.separator = "ž"
@@ -9,31 +6,24 @@ RegisterAddonMessagePrefix(aura_env.addonprefix)
---@param string string
---@param deliminer string
---@return string[]
---@return string[], string|nil
local function StrSplit(input, deliminer)
if not deliminer then return {}, "deliminer is nil" end
if not input then return {}, "input is nil" end
local parts = {}
for part in string.gmatch(input, "([^" .. deliminer .. "]+)") do
table.insert(parts, strtrim(part))
end
return parts
return parts, nil
end
---@type string[]
local toNotify = StrSplit(msg, ",")
local toNotify = StrSplit(aura_env.config.notify, ",")
for i, part in ipairs(toNotify) do
toNotify[i] = strtrim(part)
end
-- local toNotify = { "Deathleta" }
---@type Stinky[]
aura_env.stinkies = {}
local stinkies = StrSplit(msg, ",")
for i, part in ipairs(stinkies) do
local datum = StrSplit(part, ":")
local name = strtrim(datum[1])
local threat = tonumber(strtrim(datum[2] or "0"))
aura_env.stinkies[name] = Stinky.new(name, threat)
end
---@class Message
@@ -212,6 +202,14 @@ aura_env.GetZone = function()
return string.format("%s (%s)", GetZoneText(), GetSubZoneText())
end
local stinkies = StrSplit(aura_env.config.stinkies, ",")
for i, part in ipairs(stinkies) do
local datum = StrSplit(part, ":")
local name = strtrim(datum[1])
local threat = tonumber(strtrim(datum[2] or "0"))
aura_env.stinkies[name] = Stinky.new(name, threat)
end
local killSpamTime = 30
local recentlyKilled = {}
aura_env.RegisterKill = function(source, destination, spellName, overkill)
@@ -237,6 +235,7 @@ aura_env.localStinkies = {}
---@param name string
aura_env.StinkyDetected = function(name)
if aura_env.config.debug then print(string.format("StinkyDetected (%s)", name)) end
if not aura_env.localStinkies[name] or aura_env.localStinkies[name] <
GetTime() - aura_env.config.messageThrottle then
local stinky = aura_env.stinkies[name]