Originally Posted by Benio
Lua Code:
ADDON_NAME.frames.options.default = function(...) ADDON_NAME.db = ADDON_NAME.default; ADDON_NAME.libs.ConfigRegistry:NotifyChange("ADDON_NAME"); end;
It changes ADDON_NAME.db, and corresponding GUI in options panel at will.
However, it works only first time after (re)loading GUI and changes are not saved.
Problem: How to handle Defaults → "These Settings" to default it's settings and save them correctly?
|
Tables are passed by reference, what you're doing is just making
ADDON_NAME.db point to
ADDON_NAME.default instead of copying the table
So anything you do afterwards is with the table referenced in
ADDON_NAME.default instead of the dereferenced one from
ADDON_NAME.db
If you're lazy you can use Blizzard's
CopyTable for deep copying
Lua Code:
function CopyTable(settings)
local copy = {};
for k, v in pairs(settings) do
if ( type(v) == "table" ) then
copy[k] = CopyTable(v);
else
copy[k] = v;
end
end
return copy;
end
Code:
ADDON_NAME.db = CopyTable(ADDON_NAME.default)
But there also was something about AceDB tables being "magic" tables
So in that specific case I'm probably wrong, and I don't really understand that part anymore
http://forums.wowace.com/showthread.php?t=25654#3
http://forums.wowace.com/showthread.php?t=19243
http://www.wowace.com/addons/ace3/pa...-3-0-tutorial/
(Edit) would
DBObjectLib:ResetProfile() work for you?
Code:
ADDON_NAME.db:ResetProfile()