ACE3 DB default values
Hi,
i am the developer of a small ACE3 addon named RaidSummon (WoW Classic). I have a set of default ACE3 DB values (the "keywords" table). If i delete all of them and reload the UI they will get populated again with the default values. I want to be able to save them in an empty state. Also if I delete them entry by entry and add new ones - after a reload - they will still be there. Any ideas how to fix this? Code: https://github.com/isitLoVe/RaidSumm...RaidSummon.lua Steps to reproduce: start WoW default table with 3 entries will be loaded add one new entry via /rs config delete the default 3 entries reload the ui the 3 default entries are still there + the new one |
Ace3 (not ACE3, it isn't an acronym) via AceDB only saves changes if the user actually makes a change. Say you have a default of "pet" = "dog". You will see nothing in the SV file for that entry. Should the user change "pet" = "cat" then you will see MyAddOnDB.profile.pet = "cat" in the SV file.
Changing the contents of the default table on the fly won't always change because the previous data is still in memory, as you discovered. You might have to completely exit the game to test. You can add to the table and reload, but removing entries from the table might not work as intended without a complete restart. What do you mean by an "empty state"? And in your OnItialize() function you specify RaidSummonSyncDB = {} on top of self.db = LibStub("AceDB-3.0"):New("RaidSummonOptionsDB", defaults, true). Why are you setting up two saved variables, one without AceDB? For that matter, line 223 tells the addon to wipe RaidSummonSyncDB each time it is loaded. |
Side note, line 1 should begin with the word local and optionsProfile on line 209 should also be localized.
If you have multiple Lua files in your addon, you can get a reference to the main table in the other Lua files using Code:
local RaidSummon = LibStub("AceAddon-3.0"):GetAddon("RaidSummon") |
BTW, what are the types for the keywords in your options table? Am I not seeing those entries?
Code:
type = "toggle" |
Quote:
Quote:
Quote:
Quote:
I only want to store data in the variable RaidSummonOptionsDB in the SV file. No need to store RaidSummonSyncDB. |
Ah. I'll poke into this deeper later. Looking at your code and your answers above, here's another tip: if you want to reset or wipe RaidSummonSyncDB such as you do on line 255, I instead suggest you use the wipe() function. It is faster and more accurate than telling Lua to recreate the variable. This is because, using your method, Lua has to first look through the table RaidSummonSyncDB, determine if there are values, nil them, then build the table all over again. wipe() skips right to the nil step, and doesn't bother with steps 1 or 3 because it doesn't need to do those.
Code:
wipe(RaidSummonSyncDB) Code:
for i = 1, #RaidSummonSyncDB do I am also curious about lines 219 - 230. Are you intentionally creating global variables? Do they need to be global? Can those be defined as local? |
All times are GMT -6. The time now is 02:54 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI