Could work, but it could create more trouble then it would solve.
You can dodge most of the saved variable corruption with this method (written by Phanx):
Lua Code:
local defaultSettings = {
["profiles"] = {
["Default"] = {
["options"] = {
["width"] = 400,
["height"] = 600,
["scale"] = 1,
},
["frames"] = {
},
},
},
["profileKeys"] = {
},
}
local function UpgradeVariables(src, dst)
if type(src) ~= "table" then
return { }
end
if type(dst) then
dst = { }
end
for k, v in pairs(src) do
if type(v) == "table" then
dst[k] = UpgradeVariables(v, dst[k])
elseif type(v) ~= type(dst[k]) then
dst[k] = v
end
end
return dst
end
MyAddonDB = UpgradeVariables(defaultSettings, MyAddonDB)
This way if the user manages to overwrite the ["scale"] with a string, then it would reset to it's default value on load.
It's also good if you let say in a new version you want to replace the ["width"] and ["height"] values with ["size"] = 600, then it's gonna create this variable on load, to prevent nil errors for users with an older saved variables.
But i would say for multi-profile addons with import and export settings the more common way is to use the account-wide variables only.