Thread Tools Display Modes
08-29-24, 12:39 PM   #1
Ssesmar
A Deviate Faerie Dragon
Join Date: Oct 2023
Posts: 19
AceDB help

hey, this is my first time working with acedb and I have a problem, my settings that run under self.db.char are not adopted when I change a profile or create a new one, when I change this db to self.db.profile, Changes are copied/delete/reset but creating a profile or changing it causes an error.
The deleted icons of my addon that delete players are stored under ns.dbChar = self.db.char

Lua Code:
  1. function Addon:PLAYER_LOGIN() -- OnInitialize()
  2.   ns.LoadOptions(self)
  3.   ns.Addon = Addon
  4.  
  5.   -- Register Database Profile
  6.   self.db = LibStub("AceDB-3.0"):New("HandyNotes_MapNotesRetailDB", ns.defaults)
  7.   self.db.RegisterCallback(self, "OnProfileChanged", "OnProfileChanged")
  8.     self.db.RegisterCallback(self, "OnProfileCopied", "OnProfileCopied")
  9.     self.db.RegisterCallback(self, "OnProfileReset", "OnProfileReset")
  10.   self.db.RegisterCallback(self, "OnProfileDeleted", "OnProfileDeleted")
  11.  
  12.   db = self.db.profile
  13.   -- deleted icons database+
  14.   ns.dbChar = self.db.char
  15.  
  16.   -- Register options
  17.   HandyNotes:RegisterPluginDB("MapNotes", pluginHandler, ns.options)
  18.   LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("MapNotes", ns.options)
  19.  
  20.   -- Get the option table for profiles
  21.   ns.options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
  22. end

Lua Code:
  1. function Addon:OnProfileChanged(event, database)
  2.   db = database.profile
  3.   --ReloadUI();
  4.   HandyNotes:GetModule("FogOfWarButton"):Refresh()
  5.   ns.Addon:FullUpdate()
  6.   HandyNotes:SendMessage("HandyNotes_NotifyUpdate", "MapNotes")
  7. end
  8.  
  9. function Addon:OnProfileReset(event, database, profileKeys)
  10.     db = database.profile
  11.   HandyNotes:GetModule("FogOfWarButton"):Refresh()
  12.   ns.Addon:FullUpdate()
  13.   HandyNotes:SendMessage("HandyNotes_NotifyUpdate", "MapNotes")
  14. end
  15.  
  16. function Addon:OnProfileCopied(event, database)
  17.     db = database.profile
  18.   HandyNotes:GetModule("FogOfWarButton"):Refresh()
  19.   ns.Addon:FullUpdate()
  20.   HandyNotes:SendMessage("HandyNotes_NotifyUpdate", "MapNotes")
  21. end
  22.  
  23. function Addon:OnProfileDeleted(event, database)
  24.     db = database.profile
  25.   HandyNotes:GetModule("FogOfWarButton"):Refresh()
  26.   ns.Addon:FullUpdate()
  27.   HandyNotes:SendMessage("HandyNotes_NotifyUpdate", "MapNotes")
  28. end

Lua Code:
  1. local ADDON_NAME, ns = ...
  2.  
  3. ns.defaults = {
  4.  
  5.   profile = {
  6.  
  7.     --FogOfWar
  8.       colorR = 1,
  9.       colorG = 1,
  10.       colorB = 1,
  11.       colorA = 1,
  12.  
  13.   },
  14.  
  15.   char = {
  16.     -- deleted icons function
  17.       AzerothDeletedIcons = {
  18.         ['*'] = {},
  19.         }
  20.   },
  21.  
  22. }

Maybe someone can help, just write here any help is welcome

Last edited by Ssesmar : 08-31-24 at 01:58 PM.
  Reply With Quote
08-29-24, 12:57 PM   #2
Ssesmar
A Deviate Faerie Dragon
Join Date: Oct 2023
Posts: 19
Oh yes, if the code above is not enough, here is the link to the addon
https://github.com/Ssesmar/MapNote-Test
I was able to solve the problem

Last edited by Ssesmar : 08-31-24 at 01:06 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » AceDB help


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