Thread Tools Display Modes
11-23-14, 05:36 PM   #1
Benalish
A Flamescale Wyrmkin
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 123
AceDB-3.0 question

I wrote this line on the OnInitalize() event of my mod

Lua Code:
  1. self.db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults, true)
  2. db = self.db

When I run /dump db and /dump MyAddonDB, is possible they print different table? And if so, why?
  Reply With Quote
11-23-14, 08:06 PM   #2
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Benalish View Post
I wrote this line on the OnInitalize() event of my mod

Lua Code:
  1. self.db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults, true)
  2. db = self.db

When I run /dump db and /dump MyAddonDB, is possible they print different table? And if so, why?
Because the first one is a table, and the second one is a global reference, but they both point into the same table.
  Reply With Quote
11-24-14, 07:13 AM   #3
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Yes, they should be different as AceDB:New returns a different table full of magics and stuff that refers to various places in your "real" saved variables. Your global table is somewhere in there, though. I think db.sv == MyAddonDB.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
11-24-14, 06:30 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Also, once you are using AceDB, you should never do anything directly with your actual saved variable. If you want to store stuff globally (outside the selected profile) use the "global" namespace of your db:

Code:
db.profile.something = 5 <-- this is stored in the profile, eg "Default"
db.global.something = 10 <-- this is stored separately in a section available to all characters regardless of profile
There are also namespaces for "char" (specific to the current character), "faction", "realm", and a few others.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » AceDB-3.0 question


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