WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Ace3 DB Profile not copying over existing values (https://www.wowinterface.com/forums/showthread.php?t=57838)

Sweetsour 02-25-20 01:48 PM

Ace3 DB Profile not copying over existing values
 
Hello!

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.

core.lua
Lua Code:
  1. function Ace3:OnInitialize()
  2.     local about_panel = LibStub:GetLibrary("LibAboutPanel", true)
  3.  
  4.     if about_panel then
  5.         self.optionsFrame = about_panel.new(nil, "AutoTracker")
  6.     end
  7.  
  8.     self.db = LibStub("AceDB-3.0"):New("ATP_db", ATP.defaults, true)
  9.  
  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")
  14.    
  15.     self:SetupOptions()
  16.  
  17.     self.myname = UnitName("player")
  18.     self.myrealm = GetRealmName()
  19. end

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

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