Files

41 lines
1.2 KiB
Lua

---@class aura_env
---@field config table<string, any>
---@field stinkies table<string, boolean>
---@field detectedStinkies table<string, {seen: number, muteUntil: number?}>
---@field StinkyDetected fun(name: string)
aura_env.stinkies = {}
aura_env.detectedStinkies = {}
---@param input string
---@param deliminer 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, nil
end
local stinkies = StrSplit(aura_env.config.stinkies, ",")
for _, name in ipairs(stinkies) do
aura_env.stinkies[name] = true
end
aura_env.StinkyDetected = function(name)
local now = GetTime()
local existing = aura_env.detectedStinkies[name]
if not existing then
aura_env.detectedStinkies[name] = { seen = now, muteUntil = 0 }
else
existing.seen = now
end
if existing.muteUntil < now then
print(existing.muteUntil, now)
PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master")
end
aura_env.detectedStinkies[name].muteUntil = now + aura_env.config.alertThrottle
end