Fix up the log messages a lil

Unbutcher inviter
This commit is contained in:
2025-01-08 17:11:07 +01:00
parent fca49c6302
commit d3004019c6
15 changed files with 647 additions and 305 deletions

View File

@@ -14,19 +14,18 @@ function shared.Macroer.Init()
local function FindOrCreateMacro(macroName)
if Heimdall_Data.config.macroer.debug then
print(string.format("%s: FindOrCreateMacro", ModuleName))
shared.dumpTable(Heimdall_Data.config.macroer)
print(string.format("[%s] Finding or creating macro: %s", ModuleName, macroName))
end
local idx = GetMacroIndexByName(macroName)
if idx == 0 then
if Heimdall_Data.config.macroer.debug then
print(string.format("%s: Creating macro", ModuleName))
print(string.format("[%s] Creating new macro: %s", ModuleName, macroName))
end
CreateMacro(macroName, "INV_Misc_QuestionMark", "")
end
idx = GetMacroIndexByName(macroName)
if Heimdall_Data.config.macroer.debug then
print(string.format("%s: idx = %s", ModuleName, idx))
print(string.format("[%s] Macro index: %d", ModuleName, idx))
end
return idx
end
@@ -34,15 +33,21 @@ function shared.Macroer.Init()
---@param stinkies table<string, stinky>
local function FixMacro(stinkies)
if Heimdall_Data.config.macroer.debug then
print(string.format("%s: FixMacro", ModuleName))
shared.dumpTable(Heimdall_Data.config.macroer)
print(string.format("[%s] Fixing macro with %d stinkies", ModuleName, #stinkies))
end
if not Heimdall_Data.config.macroer.enabled then return end
if InCombatLockdown() then return end
if Heimdall_Data.config.macroer.debug then
print(string.format("%s: InCombatLockdown", ModuleName))
shared.dumpTable(Heimdall_Data.config.macroer)
if not Heimdall_Data.config.macroer.enabled then
if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Module disabled, skipping macro update", ModuleName))
end
return
end
if InCombatLockdown() then
if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] In combat, skipping macro update", ModuleName))
end
return
end
local priorityMap = {}
for priority, className in ipairs(Heimdall_Data.config.macroer.priority) do
priorityMap[className] = priority
@@ -56,6 +61,10 @@ function shared.Macroer.Init()
end
end
if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Processing %d non-agent stinkies", ModuleName, #sortedStinkies))
end
table.sort(sortedStinkies, function(a, b)
local aPriority = priorityMap[a.class] or minPriority
local bPriority = priorityMap[b.class] or minPriority
@@ -65,23 +74,30 @@ function shared.Macroer.Init()
local lines = { "/targetenemy" }
for _, stinky in pairs(sortedStinkies) do
if stinky.seenAt > GetTime() - 600 then
print(string.format("Macroing %s", stinky.name))
if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Adding target macro for: %s", ModuleName, stinky.name))
end
lines[#lines + 1] = string.format("/tar %s", stinky.name)
end
end
local idx = FindOrCreateMacro("HeimdallTarget")
local body = strjoin("\n", unpack(lines))
if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Updating macro with %d lines", ModuleName, #lines))
end
EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body)
end
shared.stinkyTracker.stinkies:onChange(function(value)
if Heimdall_Data.config.macroer.debug then
print(string.format("%s: onChange", ModuleName))
shared.dumpTable(Heimdall_Data.config.macroer)
print(string.format("[%s] Stinkies changed, updating macro", ModuleName))
end
FixMacro(value)
end)
print("Heimdall - Macroer loaded")
if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Module initialized", ModuleName))
end
print("[Heimdall] Macroer loaded")
end