Add more infrastructure

This commit is contained in:
2024-12-16 13:18:57 +01:00
parent 34c539c4d8
commit c4b8bb8a26
2 changed files with 35 additions and 1 deletions

View File

@@ -5,12 +5,21 @@ local addonname, shared = ...
---@class Autoloot ---@class Autoloot
---@field Init fun() ---@field Init fun()
shared.Autoloot = {} shared.Autoloot = { Init = function() end }
function shared.Autoloot.Init() function shared.Autoloot.Init()
if not shared.config.autoloot.enabled then if not shared.config.autoloot.enabled then
print("Cyka - Autoloot disabled") print("Cyka - Autoloot disabled")
return return
end end
local lootReadyFrame = CreateFrame("Frame")
lootReadyFrame:RegisterEvent("LOOT_READY")
lootReadyFrame:SetScript("OnEvent", function()
local lootInfo = GetLootInfo()
shared.DumpTable(lootInfo, 0)
--aura_env.FilterService.Run(lootInfo)
--CloseLoot()
end)
print("Cyka - Autoloot loaded") print("Cyka - Autoloot loaded")
end end

View File

@@ -10,6 +10,7 @@ local addonname, shared = ...
---@field config CykaConfig ---@field config CykaConfig
---@field data CykaData ---@field data CykaData
---@field GetOrDefault fun(table: table<any, any>, keys: string[], default: any): any ---@field GetOrDefault fun(table: table<any, any>, keys: string[], default: any): any
---@field DumpTable fun(table: table<any, any>, depth: number)
---@field Autoloot Autoloot ---@field Autoloot Autoloot
---@class CykaData ---@class CykaData
@@ -45,6 +46,30 @@ local function init()
return value return value
end end
---@param table table
---@param depth number?
shared.DumpTable = function(table, depth)
if not table then
print(tostring(table))
return
end
if depth == nil then
depth = 0
end
if (depth > 200) then
print("Error: Depth > 200 in dumpTable()")
return
end
for k, v in pairs(table) do
if (type(v) == "table") then
print(string.rep(" ", depth) .. k .. ":")
shared.DumpTable(v, depth + 1)
else
print(string.rep(" ", depth) .. k .. ": ", v)
end
end
end
shared.config = { shared.config = {
autoloot = { autoloot = {
enabled = shared.GetOrDefault(CykaPersistentData.config, { "autoloot", "enabled" }, true), enabled = shared.GetOrDefault(CykaPersistentData.config, { "autoloot", "enabled" }, true),