More structure and implement some providers and filter

This commit is contained in:
2024-12-16 13:47:33 +01:00
parent 84e44dbb7d
commit 969ffe7d48
2 changed files with 124 additions and 33 deletions

View File

@@ -20,6 +20,10 @@ local addonname, shared = ...
---@class CykaAutolootConfig
---@field enabled boolean
---@field filter CykaAutoLootFilterConfig
---@class CykaAutoLootFilterConfig
---@field gold { enabled: boolean }
local function init()
if not CykaPersistentData then CykaPersistentData = {} end
@@ -46,33 +50,38 @@ 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
---@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),
filter = {
gold = {
enabled = shared.GetOrDefault(CykaPersistentData.config, { "autoloot", "filter", "gold", "enabled" }, true),
}
}
}
}