Having this piece of code in ACE3:
Code:
local options = {
name = "testOptions",
type = "group",
args = {
test1 = {
name = "Test1",
desc = "Test1",
type = "toggle",
get = getOption,
set = setOption,
},
test2 = {
name = "Test2",
desc = "Test2",
type = "toggle",
get = getOption,
set = setOption,
},
},
}
local defaults = {
profile = {
test1 = true,
test2 = true,
},
}
self.db = LibStub("AceDB-3.0"):New("TestDB", defaults, "Default")
How can I make a general get/set function and delete all custom funtions for each of the options?
Something like:
Code:
function getOption(value)
return db.value (or whatever) -- where db.value should be self.db.profile.test1 (or test2)
end
What I want to avoid is having to make each get/set function per option:
Code:
function getTest1()
return self.db.profile.test1
end
function setTest1(value)
self.db.profile.test1 = value
end
function getTest2()
return self.db.profile.test2
end
function setTest2(value)
self.db.profile.test2 = value
end
...