Quantcast WoWInterface - View Single Post - SavedVariables saving
View Single Post
01-18-18, 04:04 PM   #1
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 80
SavedVariables saving

Hey guys,

I'm having issues with Saved Variables. I'm writing a config menu for my Addon with the help of Ace3. I really have no issues with Ace3 currently and I'm pretty happy about but i think I'm misunderstanding saved variables somehow.

I have a few of these functions (4 in total)

Lua Code:
  1. function G.ace:GetAutoRepair()
  2.     return self.db.profile.autoRepair
  3. end
  4.  
  5. function G.ace:SetAutoRepair(info, input)
  6.     self.db.profile.autoRepair = input
  7. end

The db defined is like this:

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

gempDB is in my Toc file like this
Code:
## SavedVariables: gempDB
But I can't get the variables to save correctly. Saving and reloading just resets the option to the previous state. Same with logout. I tried Logout, deleting the saved vars file for my addon and logging back in. Then It has weird defaults that I never set anywhere which are different from my default table.
And they are even different from the options that show up in the ingame menu. Changing ingame options again doesn't change anything in the saved vars file...

At the beginning some options didn't even show up in the saved vars file. Only after copy pasting them in, deleting it, restarting the game they showed up at some point.

This is my saved vars file currently so it looks like Ace3 is doing something atleast.

Lua Code:
  1. gempDB = {
  2.     ["profileKeys"] = {
  3.         ["Wraths - Proudmoore"] = "Wraths - Proudmoore",
  4.     },
  5.     ["profiles"] = {
  6.         ["Wraths - Proudmoore"] = {
  7.             ["autoRepair"] = false,
  8.             ["hideErrors"] = "always",
  9.             ["allEnemyDebuffs"] = false,
  10.             ["sellJunk"] = false,
  11.         },
  12.     },
  13. }

Could someone give me a short explanation how saved variables exactly work and how I should work with them while developing an addon.
Like when are they saved to file? Does reloading break saved vars or something? What are the defaults? etc...
  Reply With Quote