WoWInterface (
-   Lua/XML Help (
-   -   Ace3 DB Profile not copying over existing values (

Sweetsour 02-25-20 01:48 PM

Ace3 DB Profile not copying over existing values

I'm trying to finish up my addon with adding profile functionality and I'm pretty sure it's almost good too. The only issue is when I use the copy profile functionality, the values from the profile I'm trying to copy from aren't being applied to the profile of the character that's currently logged in.

Lua Code:
  1. function Ace3:OnInitialize()
  2.     local about_panel = LibStub:GetLibrary("LibAboutPanel", true)
  4.     if about_panel then
  5.         self.optionsFrame =, "AutoTracker")
  6.     end
  8.     self.db = LibStub("AceDB-3.0"):New("ATP_db", ATP.defaults, true)
  10.     self.db.RegisterCallback(self, "OnNewProfile", "OnProfileUpdate")
  11.     self.db.RegisterCallback(self, "OnProfileChanged", "OnProfileUpdate")
  12.     self.db.RegisterCallback(self, "OnProfileCopied", "OnProfileUpdate")
  13.     self.db.RegisterCallback(self, "OnProfileReset", "OnProfileUpdate")
  15.     self:SetupOptions()
  17.     self.myname = UnitName("player")
  18.     self.myrealm = GetRealmName()
  19. end

Lua Code:
  1. function Ace3:SetupOptions()
  2.     local ACFG = LibStub("AceConfigRegistry-3.0")
  3.     local ACD = LibStub("AceConfigDialog-3.0")
  5.     ACFG:RegisterOptionsTable("AutoTracker Profiles", LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db,true))
  6.     ACD:AddToBlizOptions("AutoTracker Profiles", "Profiles", "AutoTracker")
  7. end

Lua Code:
  1. local ATP, Ace3, LSM = unpack(select(2,...))
  3. local defaults = {
  4.     profile = {
  5.         continents = {
  6.             -- table contents
  7.         },
  8.     },
  9.     char = {
  10.         continents = {
  11.             -- table contents
  12.         },
  13.     }
  14. }
  16. ATP.defaults = defaults

Any ideas?

Sweetsour 02-25-20 08:37 PM

EDIT: Sorry, forgot to add the contents of my defaults.lua file.

EDIT2: I think I'm now realizing my error in that I was using Ace3.db.char when I should have been using Ace3.db.profile. Though, I'm noticing that it's not creating a profile for each character I logon to automatically anymore and just using "Default". I also have to reload my UI when I added a new profile for my addon to read it.

EDIT3: I fixed EDIT2's issue by removing "true" from Line 8 in core.lua. However, I'm noticing an error that's occurring when loading the addon for the first time and the SavedVariables file doesn't exist yet where it's saying that there's an error trying to load said file. Reloading the UI fixes the issue, but that shouldn't be required to do. Any ideas why that's happening?

Rilgamon 02-26-20 12:42 AM

Your functions are stored in the Ace3 namespace.
They should be in your own?
Edit: ups, nvm I See Ace3 is local for you. But I'd guess this might kick you in the but somewhere.

myrroddin 02-26-20 03:35 PM

AceDB-3.0 only writes to the saved variables if the user makes a change from the default value; otherwise it is a series of mostly empty tables.

I do not see an options table being registered, and why are you registering your profiles like that? That is very weird.

All times are GMT -6. The time now is 12:55 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2019 MMOUI