View Single Post
10-29-23, 02:07 AM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
This still doesn't make any sense to me. I see no API to register module options; I do see two to register module defaults. When I try to register the module options, I get the error telling me that the module is already registered, presumably when I registered the namespace. How then do I assign the options? Is this done with AceConfig, with appName being the module name? If that is true, which I'm not sure about, will doing so merge the module options with the core options?

addon is defined in the core file, and module is defined in the module file. This chunk is from the core file.
Lua Code:
  1. -- functions to register module options and check if a module is registered
  2. local moduleOrder = 100
  3. function addon:RegisterModuleOptions(moduleName, optionsTable)
  4.     if options.args[moduleName] == nil then
  5.         options.args[moduleName] = optionsTable
  6.         options.args[moduleName].order = moduleOrder
  7.         options.args[moduleName].name = optionsTable and optionsTable.name or moduleName
  8.         moduleOrder = moduleOrder + 10
  9.     else
  10.         error(moduleName .. " is already registered", 2)
  11.     end
  12. end
  13.  
  14. function addon:IsModuleAlreadyRegistered(moduleName)
  15.     return options.args[moduleName] and true or false
  16. end

This chunk is in the module file.
Lua Code:
  1. function module:OnInitialize()
  2.     self.db = addon.db:RegisterNamespace("Chat", defaults)
  3.     db = self.db.profile
  4.     self:SetEnabledState(db.enabled)
  5.  
  6.     local options = self:GetOptions()
  7.     addon:RegisterModuleOptions("Chat", options)
  8. end

And after all of that, how do I reset the module when the profile is reset via the core file?
  Reply With Quote