AceDB lost default values on SetProfile
Hello.
I'm trying to use profiles in one of my addons and everything works fine until I change the profile, where I lose every default value. Let's say I have the next code: Code:
local PROFILE_DEFAULTS = { Now I change some settings where I change the value of "anotherValue" to "changed". When I logout, I can see in my savedVariables.lua the next table: Code:
["profileKeys"] = { Code:
private.db:SetProfile("profile1") If I reset the UI then everything works again, and I have both values. I tried using AceDBOptions, and I get the same result. Am I doing something wrong in here? Thanks. |
AceDB only writes settings that have been altered to the SavedVariables file. It does not write if nothing has been changed.
In your example, defaultValue has a default of true; you did not change it to false, "Ted", or 007, it is still true. Therefore it is nil in your SV file. Nothing is lost. In fact, it retains the default value from PROFILE_DEFAULTS in memory. BTW, here's a tip: change this line. This will create a literal profile called Default in the Profiles options tree when presented to the user. You will see what I mean when you load into the game. It makes the life of the user a lot easier. Code:
self.db = LibStub("AceDB-3.0"):New("MyAddonDB", PROFILE_DEFAULTS, true) -- add true to the end https://www.wowace.com/projects/ace3...api/ace-db-3-0 |
I was giving this some thought. I advise you to not programmatically set profiles for the user. That is really what an addon like Reflux is for. Instead, let the user decide how to manage their profiles.
Again, tack on the word true at the end of that initialization code and see if that is what you wanted. |
Hey myrroddin.
Thanks for your help and your time. I found what the problems was. I needed to add all these handlers to reload my "private.db" value. Code:
self.db = LibStub("AceDB-3.0"):New("MyAddonDB", PROFILE_DEFAULTS) |
All times are GMT -6. The time now is 10:40 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI