Refactor TSU to event3 from event1
This commit is contained in:
@@ -1,55 +1,6 @@
|
||||
-- COMBAT_LOG_EVENT_UNFILTERED TICKER_1000
|
||||
---@param allstates allstates
|
||||
-- COMBAT_LOG_EVENT_UNFILTERED
|
||||
---@param e string
|
||||
function(allstates, e, ...)
|
||||
if e == "TICKER_1000" then
|
||||
local ttl = aura_env.config.ttl or 120
|
||||
for _, state in pairs(allstates) do
|
||||
if state.progress then
|
||||
local elapsedTime = GetTime() - state.index
|
||||
if elapsedTime > ttl then
|
||||
state.show = false
|
||||
state.changed = true
|
||||
else
|
||||
local prettyTime = ""
|
||||
|
||||
local minutes = 0
|
||||
while elapsedTime > 60 do
|
||||
elapsedTime = elapsedTime - 60
|
||||
minutes = minutes + 1
|
||||
end
|
||||
if minutes > 0 then
|
||||
prettyTime = string.format("%s%dm", prettyTime, minutes)
|
||||
end
|
||||
if elapsedTime > 0 then
|
||||
prettyTime = string.format("%s %ds", prettyTime, elapsedTime)
|
||||
end
|
||||
|
||||
state.progress = string.format("%20s", prettyTime)
|
||||
state.changed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1, 40 do
|
||||
if UnitIsPlayer("nameplate" .. i) then
|
||||
local name = UnitName("nameplate" .. i)
|
||||
local faction = UnitFactionGroup("nameplate" .. i)
|
||||
local _, race = UnitRace("nameplate" .. i)
|
||||
local raceFaction = aura_env.raceFactions[race]
|
||||
if not raceFaction then
|
||||
print("Unknown race faction", race)
|
||||
else
|
||||
faction = raceFaction
|
||||
end
|
||||
WeakAurasSaved.Cyka.PlayerFactionCache[name] = faction
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
function(e, ...)
|
||||
local detected = false
|
||||
local stinky = ""
|
||||
|
||||
@@ -72,17 +23,6 @@ function(allstates, e, ...)
|
||||
|
||||
if detected then
|
||||
aura_env.StinkyDetected(stinky)
|
||||
allstates[stinky] = {
|
||||
show = true,
|
||||
changed = true,
|
||||
name = string.format("%-30s", stinky),
|
||||
progressType = "timed",
|
||||
duration = 60,
|
||||
expirationTime = GetTime() + 60,
|
||||
autohide = true,
|
||||
index = GetTime(),
|
||||
progress = string.format("%20s", "0s"),
|
||||
}
|
||||
end
|
||||
|
||||
local overkill, err = CLEUParser.GetOverkill(...)
|
||||
@@ -94,13 +34,13 @@ function(allstates, e, ...)
|
||||
local spellName, err = CLEUParser.GetSpellName(...)
|
||||
if err ~= nil then spellName = "unknown" end
|
||||
local sourceid, err = CLEUParser.GetSourceGUID(...)
|
||||
if err then
|
||||
if err and aura_env.config.debug then
|
||||
print("Could not get source id for " .. source)
|
||||
print(...)
|
||||
return true
|
||||
end
|
||||
local destid, err = CLEUParser.GetDestGUID(...)
|
||||
if err then
|
||||
if err and aura_env.config.debug then
|
||||
print("Could not get destination id for " .. destination)
|
||||
print(...)
|
||||
return true
|
||||
|
@@ -1,9 +1,73 @@
|
||||
-- CHAT_MSG_ADDON
|
||||
function(e, prefix, msg, ...)
|
||||
print(string.format("e = %s", e))
|
||||
print(string.format("prefix = %s", prefix))
|
||||
print(string.format("msg = %s", msg))
|
||||
for i = 1, select("#", ...) do
|
||||
print(string.format("arg %d = %s", i, select(i, ...)))
|
||||
-- CHAT_MSG_ADDON TICKER_1000
|
||||
---@param allstates allstates
|
||||
---@param e string
|
||||
---@param prefix string
|
||||
---@param msg string
|
||||
function(allstates, e, prefix, msg, ...)
|
||||
if e == "TICKER_1000" then
|
||||
local ttl = aura_env.config.ttl or 120
|
||||
for _, state in pairs(allstates) do
|
||||
if state.progress then
|
||||
local elapsedTime = GetTime() - state.index
|
||||
if elapsedTime > ttl then
|
||||
state.show = false
|
||||
state.changed = true
|
||||
else
|
||||
local prettyTime = ""
|
||||
|
||||
local minutes = 0
|
||||
while elapsedTime > 60 do
|
||||
elapsedTime = elapsedTime - 60
|
||||
minutes = minutes + 1
|
||||
end
|
||||
if minutes > 0 then
|
||||
prettyTime = string.format("%s%dm", prettyTime, minutes)
|
||||
end
|
||||
if elapsedTime > 0 then
|
||||
prettyTime = string.format("%s %ds", prettyTime, elapsedTime)
|
||||
end
|
||||
|
||||
state.progress = string.format("%20s", prettyTime)
|
||||
state.changed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1, 40 do
|
||||
if UnitIsPlayer("nameplate" .. i) then
|
||||
local name = UnitName("nameplate" .. i)
|
||||
local faction = UnitFactionGroup("nameplate" .. i)
|
||||
local _, race = UnitRace("nameplate" .. i)
|
||||
local raceFaction = aura_env.raceFactions[race]
|
||||
if not raceFaction then
|
||||
print("Unknown race faction", race)
|
||||
else
|
||||
faction = raceFaction
|
||||
end
|
||||
WeakAurasSaved.Cyka.PlayerFactionCache[name] = faction
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if not prefix or prefix ~= aura_env.addonprefix then return end
|
||||
local data = string.split(msg, aura_env.separator)
|
||||
local name = data[1]
|
||||
local threat = data[2]
|
||||
local note = data[3]
|
||||
|
||||
allstates[stinky] = {
|
||||
show = true,
|
||||
changed = true,
|
||||
name = string.format("%-30s", stinky),
|
||||
progressType = "timed",
|
||||
duration = 60,
|
||||
expirationTime = GetTime() + 60,
|
||||
autohide = true,
|
||||
index = GetTime(),
|
||||
progress = string.format("%20s", "0s"),
|
||||
}
|
||||
|
||||
return true
|
||||
end
|
Reference in New Issue
Block a user