Thread Tools Display Modes
12-08-17, 11:06 PM   #1
Sweetsour
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 130
AceDB not building table

I've been at this for hours and I'm not sure why it isn't working. I've been successful with AceDB with my previous Addon, but the only thing ending up in this addon's SavedVariables table is the profile keys; the data shown in the "defaults" table below is nowhere to be found.

File Structure
Code:
[root_folder]
[Libs]
[AceAddon-3.0] [AceConfig-3.0] [AceConsole-3.0] [AceDB-3.0] [AceEvent-3.0] [AceGUI-3.0] [AceHook-3.0] [AceTimer-3.0] [CallbackHandler-1.0] [LibStub] Ace3.lua Ace3.toc load_libraries.xml
core.lua SuperCrits.toc
load_llibraries.xml
xml Code:
  1. <Ui xmlns="http://www.blizzard.com/wow/ui/">
  2.     <Script file="LibStub\LibStub.lua"/>
  3.     <Include file="CallbackHandler-1.0\CallbackHandler-1.0.xml"/>
  4.     <Include file="AceAddon-3.0\AceAddon-3.0.xml"/>
  5.     <Include file="AceEvent-3.0\AceEvent-3.0.xml"/>
  6.     <Include file="AceConsole-3.0\AceConsole-3.0.xml"/>
  7.     <Include file="AceDB-3.0\AceDB-3.0.xml"/>
  8.     <Include file="AceTimer-3.0\AceTimer-3.0.xml"/>
  9.     <Include file="AceHook-3.0\AceHook-3.0.xml"/>
  10.     <Include file="AceConfig-3.0\AceConfig-3.0.xml"/>
  11.     <Script file="LibDataBroker\LibDataBroker-1.1.lua"/>
  12. </Ui>

TOC File
Code:
## Interface: 70300
## Title: Super Crits
## Notes: Super Crits Description
## Author: Sweetsour
## Version: r01-beta
## SavedVariables: SCritsDB

## OptionalDeps: Ace3, LibAboutPanel

Libs\load_libraries.xml

core.lua
core.lua
Lua Code:
  1. local FOLDER_NAME, SC = ...
  2.  
  3. local SCrits = LibStub('AceAddon-3.0'):NewAddon("SuperCrits", 'AceConsole-3.0','AceEvent-3.0','AceHook-3.0','AceTimer-3.0')
  4.  
  5. local defaults = {
  6.     char = {
  7.         damaging = {
  8.             pet = true,
  9.             dots = true,
  10.             damage = true,
  11.             threshold = {
  12.                 enabled = false,
  13.                 value = 2000000,
  14.             },
  15.         },
  16.     },
  17. }
  18.    
  19. function SCrits:OnInitialize()
  20.     self.db = LibStub("AceDB-3.0"):New("SCritsDB",defaults)
  21. end
  22.  
  23. function SCrits:OnEnable()
  24.     self:RegisterEvent("PLAYER_REGEN_DISABLED")
  25. end
  26.  
  27. function SCrits:PLAYER_REGEN_DISABLED()
  28.     self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  29.     self:RegisterEvent("PLAYER_REGEN_ENABLED")
  30. end
  31.  
  32. function SCrits:PLAYER_REGEN_ENABLED()
  33.     self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  34.     self:UnregisterEvent("PLAYER_REGEN_ENABLED")
  35. end
  36.  
  37. function SCrits:COMBAT_LOG_EVENT_UNFILTERED(event,...)
  38.  
  39. end

Last edited by Sweetsour : 12-08-17 at 11:46 PM.
  Reply With Quote
12-09-17, 09:08 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
I don't know Ace at all so I might be missing something but I see nowhere that defaults gets written (copied) to the SavedVariables table.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
12-09-17, 11:20 AM   #3
Sweetsour
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 130
Line 20 in core.lua should be doing it. According to the official AceDB docs, it's correct. Just not sure why the table isn't showing up
  Reply With Quote
12-09-17, 03:19 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
iirc, the only time something gets written to the saved variables with Ace3-DB is when a profile has changed a setting from the defaults.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-10-17, 09:04 AM   #5
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Not sure, you create defaults for char but you only define the global db?
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
12-10-17, 10:08 AM   #6
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
What Seerah said. AceDB does not write anything to the SV file except for the profile keys, unless something has been changed by the user. If the value in the defaults table is the same as the user settings, there is no change, therefore nothing is written into the saved variables file.

Rilgamon, what Sweetsour wrote in his .toc is correct for AceDB, although you can use saved variables per character as well if you wanted. However, I always felt that was unnecessary since AceDB can use any combination of global, profile, char, faction, and a few other variants.

I do have one suggestion to make about line 20. Change it to include the true argument at the end. This will create a profile called Default when loaded into the game.
Lua Code:
  1. self.db = LibStub("AceDB-3.0"):New("SCritsDB", defaults, true)

Last edited by myrroddin : 12-10-17 at 10:11 AM. Reason: advice for line 20
  Reply With Quote
12-10-17, 10:13 AM   #7
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Oh, I just noticed that your OptionalDeps line in your .toc is missing LibStub and CallbackHandler-1.0, which should be listed before Ace3.

... And double check the order of your listed Ace3 components in load_libraries.xml. The listed order should exactly match the order listed in Ace3.toc. You do not need to list all the components if you aren't using them, but whichever ones you are using will depend on the load order of other components.

Last edited by myrroddin : 12-10-17 at 10:17 AM. Reason: is Ace3 being loaded correctly?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » AceDB not building table

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