AceDB get defalut values? - WoWInterface
Thread Tools Display Modes
Prev Previous Post   Next Post Next
07-23-20, 04:04 PM   #1
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jul 2020
Posts: 3
AceDB get defalut values?

Hello there! I'm newbie on Lua and Addon writing in general. Now i'm trying to create one simple addon based on Ace3, that handle players tracking spells and switches between them at a certain interval.

For now i'm stucked on one point that i can't access\iterate through the default options values using for-do loop.

For example i have a DB with defaults:

Lua Code:
  1. local defaults = {
  2.   profile  = {
  3.     enable = true,
  4.     trackOnlyWhileMoving = true,
  5.     castInterval = 2,
  6.     type1 = "minerals",
  7.     type2 = "herbs",
  8.     trackingTypes = {
  9.       ['*'] = true
  10.     },
  11.   }
  12. }
  14. self.db = LibStub("AceDB-3.0"):New("ResourceAutoTrackerCharDB", defaults, true)

How can i iterate through the
Lua Code:
  1. self.db.profile["trackingTypes"]
to get its keys and values if they in default state (not changed by user, not saved in SV file)?

I found that this way doesn't work for me(
Lua Code:
  1. for key, val in pairs(self.db.profile["trackingTypes"]) do
  2.   print(key, ', ', val)
  3. end

print method returns empty string...

But if i refer directly to the
Lua Code:
  1. self.db.profile["trackingTypes"]["key"]
i can get its default value.

*i hope you understand what i was ment. sorry for my bad eng)

Last edited by MickeyPickey : 07-23-20 at 04:11 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » AceDB get defalut values?

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