Thread Tools Display Modes
01-19-21, 04:46 AM   #1
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
AceDB writing random empty entries in SavedVariables

This is the minimal working example.

Core.lua:
Lua Code:
  1. Addon = LibStub("AceAddon-3.0"):NewAddon("mwe3")
  2.  
  3. Addon.defaults = {
  4.   profile = {
  5.     mySituations = {
  6.       -- Default values for all situations.
  7.       ["**"] = {
  8.           someValue = 0,
  9.       },
  10.       -- Specific values for single situations.
  11.       -- (No entries needed for minimal working example.)
  12.       ["001"] = {},
  13.       ["002"] = {},
  14.       ["003"] = {},
  15.       ["004"] = {},
  16.       ["005"] = {},
  17.       ["006"] = {},
  18.       ["007"] = {},
  19.       ["008"] = {},
  20.       ["009"] = {},
  21.       ["010"] = {},
  22.     },
  23.   },
  24. }
  25.  
  26. function Addon:OnInitialize()
  27.   db = LibStub("AceDB-3.0"):New("myDB", self.defaults, true)
  28.  
  29.   -- Normally calling this in a different context, but for the minimal
  30.   -- working example it suffices to call it here.
  31.   next(db.profile.mySituations)
  32. end


After at least two /reload I get the following in my SavedVariables/<ACCOUNT>/mwe3.lua file:
Lua Code:
  1. myDB = {
  2.     ["profileKeys"] = {
  3.         ["Mycharacter - Myrealm"] = "Default",
  4.     },
  5.     ["profiles"] = {
  6.         ["Default"] = {
  7.             ["mySituations"] = {
  8.                 ["007"] = {
  9.                 },
  10.                 ["005"] = {
  11.                 },
  12.                 ["003"] = {
  13.                 },
  14.                 ["008"] = {
  15.                 },
  16.                 ["001"] = {
  17.                 },
  18.                 ["006"] = {
  19.                 },
  20.                 ["004"] = {
  21.                 },
  22.             },
  23.         },
  24.     },
  25. }

Only some seemingly random keys get entries here. Why?
I know this does not break anything, but I would like to understand what's going on.
Thanks!


These are my toc and embeds.xml files:

mwe3.toc:
Lua Code:
  1. ## Interface: 90001
  2. ## Title: mwe3
  3. ## SavedVariables: myDB
  4. embeds.xml
  5. Core.lua

embeds.xml:
Lua Code:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.blizzard.com/wow/ui/" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
  3. ..\FrameXML\UI.xsd">
  4.     <Script file="Libs\LibStub\LibStub.lua"/>
  5.     <Include file="Libs\AceAddon-3.0\AceAddon-3.0.xml"/>
  6.     <Include file="Libs\AceDB-3.0\AceDB-3.0.xml"/>
  7. </Ui>
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » AceDB writing random empty entries in SavedVariables

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