Hello!
What i'm trying to do is, create different options for my addon for many different elements and AceDB should store those options in a variable looking something like this:
Code:
options = {
showInCombat = true,
icons = {
width = 20,
height = 20,
},
bars = {
width = 200,
height = 30,
bar1 = {
color = "green",
},
bar2 = {
color = "red",
},
},
}
but currently it still looks like this:
Code:
options = {
showInCombat = true,
iconWidth = 20,
iconHeight = 20,
barWidth = 200,
barHeight = 30,
bar1Color = "green",
bar2Color = "red",
}
Right now i have following 'set' (AceConfig) function:
Code:
function addon:SetSliderValue(info, value)
local key = info[#info];
db[key] = value;
end
"key" would be something like bar1Color, barWidth and so on, the variable name that will be filled with the value that got changed.
But i think it would look better and be more organized if all the options for the specific elements would be grouped together in nested tables.
My problem is, i don't know how to rewrite the 'set' function to do that.
I need something like this:
Code:
function addon:SetSliderValue(info, value)
local rootNode = info[1]; -- "bar"
local secondNode = info[2]; -- "bar1";
local thirdNode = info[3]; -- "color";
-- db[rootNode][secondNode][thirdNode] = value;
-- db.rootNode.secondNode.thirdNode = value;
end
And this part is where i don't know how to do it.
I searched on google but didn't really know what to search for, so came up with nothing related to my problem.
Is this somehow possible? Is this even a good idea?
Or should i create a new function for every "layer", db.bars[key] = value, db.bars.bar1[key] = value and so on?
But one function would be so much simpler to maintain... :O