Thread: Saved Variables
View Single Post
11-24-14, 06:47 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Please don't quote an entire 100+ line post, especially if it's the last post in the thread.

Originally Posted by cokedrivers View Post
How would you use these defaults in your addon would it be MyAddonDB.x ?
Yes. The defaults are just that -- default values. They should only be used to initialize the db table; you should never be referring to values in the defaults table or applying them to things in your addon. If you're currently doing this with AceDB:

Code:
local defaults = {
     global = {
          point = "TOP",
          x = 0,
          y = -100,
     }
}

local db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults, true)
local cfg = db.global

SomeFrame:SetPoint(cfg.point, cfg.x, cfg.y)
Then using the method in my last post you would do this instead:

Code:
local defaults = {
     point = "TOP",
     x = 0,
     y = -100,
}

MyAddonDB = copyDefaults(defaults, MyAddonDB)
local cfg = MyAddonDB

SomeFrame:SetPoint(cfg.point, cfg.x, cfg.y)
However, if you want to offer profile support, I'd suggest you just continue using AceDB.

Also, this thread is very old. I suggest you check this more current one instead:
http://forums.wowace.com/showthread.php?t=21864
__________________
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.

Last edited by Phanx : 11-24-14 at 06:51 PM.
  Reply With Quote