From c4b8bb8a2655e23c10acd62e95e21222684bd503 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Mon, 16 Dec 2024 13:18:57 +0100 Subject: [PATCH] Add more infrastructure --- Autoloot.lua | 11 ++++++++++- Cyka.lua | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Autoloot.lua b/Autoloot.lua index c93fd9f..0517dc4 100644 --- a/Autoloot.lua +++ b/Autoloot.lua @@ -5,12 +5,21 @@ local addonname, shared = ... ---@class Autoloot ---@field Init fun() -shared.Autoloot = {} +shared.Autoloot = { Init = function() end } function shared.Autoloot.Init() if not shared.config.autoloot.enabled then print("Cyka - Autoloot disabled") return 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") end diff --git a/Cyka.lua b/Cyka.lua index 5af6503..4eb21f0 100644 --- a/Cyka.lua +++ b/Cyka.lua @@ -10,6 +10,7 @@ local addonname, shared = ... ---@field config CykaConfig ---@field data CykaData ---@field GetOrDefault fun(table: table, keys: string[], default: any): any +---@field DumpTable fun(table: table, depth: number) ---@field Autoloot Autoloot ---@class CykaData @@ -45,6 +46,30 @@ local function init() return value 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 = { autoloot = { enabled = shared.GetOrDefault(CykaPersistentData.config, { "autoloot", "enabled" }, true),