Quantcast Ace3 DB Profile not copying over existing values - WoWInterface
 
Thread Tools Display Modes
02-25-20, 01:48 PM   #1
Sweetsour
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 128
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?

Last edited by Sweetsour : 02-25-20 at 08:37 PM. Reason: added defaults.lua contents
  Reply With Quote
02-25-20, 08:37 PM   #2
Sweetsour
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 128
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?

Last edited by Sweetsour : 02-25-20 at 09:11 PM.
  Reply With Quote
02-26-20, 12:42 AM   #3
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 757
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.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
02-26-20, 03:35 PM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,107
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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Ace3 DB Profile not copying over existing values

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off