1. Hello,

    I've been working on an addon, using ace3 libraries, and now I'd like to let users be able to set up some "preferences". Since I've never used saved variables before,I've been looking them up on google and found out that AceDB could let me manage them.

    So far so good. But I just fail at saving preferences, so if I have my option frame that contains fields to change preferences values, I'd like them to be saved. Here's what I'm doing

     MyImbaAddon = LibStub("AceAddon-3.0"):NewAddon("MyImbaAddon", "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0")
    
     local AceGUI = LibStub("AceGUI-3.0")
    
     local mainFramePosition = nil
     local mainFrameWidth = nil
     local mainFrameHeight = nil
     local updateFrequency = nil
    
     local Defaults = {
    
         global = {
            enabled = true,
             position = { MyImbaAddonAnchor =  {"CENTER",nil,"CENTER",0,190} },
             frequency = 0.5,
             size = { x = 450, y = 150 },
    
        },
     }
    
     function MyImbaAddon:OnInitialize()
       -- do init tasks here, like loading the Saved Variables, 
       -- or setting up slash commands.
         MyImbaAddon:RegisterChatCommand("aet", "AETSlashCommand")
    
         self.db = LibStub("AceDB-3.0"):New("MyImbaAddonDB",Defaults,"Default")
    
         self:InitOptions()
     end
    
    
     function MyImbaAddon:InitOptions()
         if (self.db.profile.frequency == nil) then
             updateFrequency = self.db.global.frequency
             self.db.profile.frequency = updateFrequency
         else
             updateFrequency =  self.db.profile.frequency
         end
         if  (self.db.profile.position == nil) then
             mainFramePosition = self.db.global.position
             self.db.profile.position = mainFramePosition
         else
             mainFramePosition = self.db.profile.position
         end
    
         if (self.db.profile.size == nil) then
             mainFrameWidth = self.db.global.size.x
             self.db.profile.size = {x = mainFrameWidth}
         else
             mainFrameWidth = self.db.profile.size.x
         end
    
         if (self.db.profile.size.y == nil) then
             mainFrameHeight = self.db.global.size.y
             self.db.profile.size.y = mainFrameHeight
         else
             mainFrameHeight  = self.db.profile.size.y
         end
    
         self:Print("frequency="..updateFrequency)
     end
    

    now imagine i have a field in my options GUI that has the following code :

         frequencyEdit:SetCallback("OnEnterPressed", function(arg1, arg2, arg3) 
             self.db.profile.frequency = arg3
         end)
    

    but the value never gets saved; so when i print frequency= i always get frequency=0.5 which is the default value. Also i'm not sure what i'm doing in InitOptions is the best =P but I tried.. :D

    any help would be really appreciated. Essentially I want to have default settings, and when the user changes some settings, have them updated and loaded properly next login.

    Did you put the savedvariable name(s) in the TOC?

    ## SavedVariables: SavedVariableName or ## SavedVariablesPerCharacter: SavedVariableName

    yeah i did that

    Did you add a print statement to see if your callback ever actually gets called? If you set the value using a script you should see it saved. Try both of those!

    i also did that :<

    coz at first i didnt know which event of arg1, arg2, arg3 was the event that contained the new value, so i was printing the arguments first.... so yeah i'm also sure the callback method is being called.. thanks for the thought though ^^

    Then I'm not particularly sure what to tell you. Try experimenting on the commandline to see if any changes you make even manually are ever saved.