Defaults "These Settings" handle
Hey, I made an addon that uses Ace3:
It stores options, adds it to Blizzard Addon options page, saves beetween sessions etc. However, when I click Interface → Options → AddOns → Defaults → These Settings, nothing happens. Lua Code:
Lua Code:
Lua Code:
I tried to implement it according to some comments I saw, using: Lua Code:
Lua Code:
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? Any manual page, tutorial, examples or direct solution would be appreciated. |
Quote:
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:
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() |
Thanks for a reply! Actually, ResetDB with CopyTable makes change permanent.
Unfortunatelly, it looks like I still need to reload UI in order to make GUI active again (clicking checkbox changes it's visuals, and related ADDON_NAME.db.global setting, but those are not saved on reloading UI). Lua Code:
edit: ResetProfile makes nothing, even with previously RegisterDefaults. edit2: ResetDB defaults .db already thanks to second parameter of New, so no CopyTable is needed. Instead, we need to just reinitialize database since it's reset: Lua Code:
Works like a charm. Final Note: Thanks, Ketho, for pointing out that passing table by reference won't work. Thanks that, and the linked threads, connected with the "magic" issue, I found out how to handle it. For futher reference, I am pasting the corrected code: Lua Code:
Lua Code:
Lua Code:
|
I was working on the same thing last night- ha!
I did a little example addon for others in case they get stuck too. Not as detailed as your stuff, but might help others get off the ground. It is @ https://github.com/ChrisNolan/TestAd...hor=ChrisNolan |
All times are GMT -6. The time now is 09:19 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI