For some reason the db isn't properly fetched from DreamTweaks (that why it's nil and causes an error). In which order are your files loaded ? BTW how do all your files look like now ? (Use http://www.wowace.com/paste/ and copy the link there, don't paste the file content directly in the forum).
Thank you for all your help on this. I am still very new to coding and I learn from doing things trial by error not a book learner. I have the world of warcraft wrath Lua book and the Lua with world of warcraft addons. But there is not any good info on Ace3 in them. So again just want to thank you for baring with me on all of this.
Ok, so, I see that :
- in Core.lua, you are not enabling nor disabling the module but only changing the settings, that's why OnDisable is never called,
- in ActionBars.lua, there is no OnInitialize that would fill the local db variable. This is what causes the errors.
By the way, in Core.lua your creating some global functions (StyleShapeshift, StylePet). This is wrong because it could cause conflicts with other addons using the same names. Moreover your global ActionButton_OnUpdate function will just overwrite Blizzard one and probably cause lots of trouble. Either make them local (if your only use them in Core.lua, or make them methods of your addon if you use them in other files).
You are also creating frame with name like Recount or Omen, this is very bad because these names are used to create global variables pointing to the frames. Your are probably overwriting the addons with these. Choose another names. Moreover, if you want your addon to properly detect these addons, you should list them in the OptionalDeps field of your TOC, so your addon does not get loaded before them.
Ok, so, I see that :
- in Core.lua, you are not enabling nor disabling the module but only changing the settings, that's why OnDisable is never called,
- in ActionBars.lua, there is no OnInitialize that would fill the local db variable. This is what causes the errors.
By the way, in Core.lua your creating some global functions (StyleShapeshift, StylePet). This is wrong because it could cause conflicts with other addons using the same names. Moreover your global ActionButton_OnUpdate function will just overwrite Blizzard one and probably cause lots of trouble. Either make them local (if your only use them in Core.lua, or make them methods of your addon if you use them in other files).
You are also creating frame with name like Recount or Omen, this is very bad because these names are used to create global variables pointing to the frames. Your are probably overwriting the addons with these. Choose another names. Moreover, if you want your addon to properly detect these addons, you should list them in the OptionalDeps field of your TOC, so your addon does not get loaded before them.
Ok I added the Recount and Omen to the toc.
I moved all the code for the styling the buttons in with the code for the action bars Module.
Not sure what you mean on the "in Core.lua, you are not enabling nor disabling the module but only changing the settings" every exampel I have seen for the defalts only have the {Enable = true,} I however removed the {Disable = false,} that was there cus i was testing to see if that would do anything.
? " in ActionBars.lua, there is no OnInitialize that would fill the local db variable. This is what causes the errors."
Not sure what you mean on the "in Core.lua, you are not enabling nor disabling the module but only changing the settings" every exampel I have seen for the defalts only have the {Enable = true,} I however removed the {Disable = false,} that was there cus i was testing to see if that would do anything.
According to what you pasted, in the set methods of the config options (in Core.lua), you are doing this :
set = function(info, val)
db.ActionBars.Enable = val
DreamTweaks:GetModule("ActionBars"):ApplyConfig()
end,
This will never enable nor disable the ActionBars module by calling DreamTweaks:GetModule("ActionBars"):Enable() (or DreamTweaks:EnableModule("ActionBars") which is basically the same thing) and DreamTweaks:GetModule("ActionBars"):Disable(). So your modules are always enabled and never disabled.
You have to make up your mind : do you want to have several modules you can fully enable/disable and take advantage of this ? By example, disabling a module automatically disable all associated AceHook hooks and AceEvent listeners ; each module has its own set of event handlers. You could also add a :GetOptions() methods to each module and iterate them to build the main addon options. Each module can also have its own AceDB namespace by using self.db = DreamTweaks.db:RegisterNamespace(self.name, someDefaults). Etc...
If all you want is to split your code amongst several files and not the above fancy stuff, you do not need modules, just split the code, adding "public" methods to DreamTweaks so they are visible from every file.
Note that some fancy uses of modules aren't that easy to set up, especially the GetOptions part. And since you are still struggling with db and upvalues, the AceDB namespacing thing is probably a bit complicated too.
<snip>
If all you want is to split your code amongst several files and not the above fancy stuff, you do not need modules, just split the code, adding "public" methods to DreamTweaks so they are visible from every file.
<snip>
You can also make an AddOn-local table (visible ONLY to files in your AddOn) by doing this at the top of every file:
local ADDON_NAME, PRIVATE_TABLE = ...
You can name these anything you like; I simply gave them those names to illustrate their usage.
From there, you can do things like:
function PRIVATE_TABLE:DoSomething()
-- Do stuff here
end
This method would be visible throughout your AddOn, and nowhere else.
You have to make up your mind : do you want to have several modules you can fully enable/disable and take advantage of this ? By example, disabling a module automatically disable all associated AceHook hooks and AceEvent listeners ; each module has its own set of event handlers. You could also add a :GetOptions() methods to each module and iterate them to build the main addon options. Each module can also have its own AceDB namespace by using self.db = DreamTweaks.db:RegisterNamespace(self.name, someDefaults). Etc...
I think this is what I should do. I latter plan to add more Modules. If I added more modules wouldn't this be the better way to go. So I don't have to keep adding code to the core and config file. Or would I still have to add things for every module I add?
I have tried reading the Ace3 site pages but its not newbie friendly. Is there any other tutorials that are easier to understand?
In ActionBars.lua, I only see code that do stuff when the module is enabled but not when it is disabled. Disabling a module will only disable related stuff that has been written to handle it, like AceEvent, AceHook and AceTimer. Nothing else is automagically reverted ; you have to explicitly revert any other thing you've done on enable.
Ok I have been working so hard this last few weeks but still having some problems, I don't understand the Action Bar module works fine no error, well no error till i do a change profile or reset default. But the strangest error is this one.
Message: Interface\AddOns\DreamTweaks\modules\Minimap.lua:125: attempt to index field 'db' (a nil value)
Time: 09/23/11 23:31:35
Count: 1
Stack: Interface\AddOns\DreamTweaks\modules\Minimap.lua:125: in function <Interface\AddOns\DreamTweaks\modules\Minimap.lua:124>
(tail call): ?
[C]: ?
[string "safecall Dispatcher[1]"]:9: in function <[string "safecall Dispatcher[1]"]:5>
(tail call): ?
...ddOns\DreamTweaks\libs\AceAddon-3.0\AceAddon-3.0.lua:543: in function <...ddOns\DreamTweaks\libs\AceAddon-3.0\AceAddon-3.0.lua:536>
(tail call): ?
Interface\AddOns\DreamTweaks\DreamTweaks.lua:97: in function `Settings'
Interface\AddOns\DreamTweaks\DreamTweaks.lua:90: in function <Interface\AddOns\DreamTweaks\DreamTweaks.lua:76>
(tail call): ?
[C]: ?
[string "safecall Dispatcher[1]"]:9: in function <[string "safecall Dispatcher[1]"]:5>
(tail call): ?
...ddOns\DreamTweaks\libs\AceAddon-3.0\AceAddon-3.0.lua:514: in function `InitializeAddon'
...ddOns\DreamTweaks\libs\AceAddon-3.0\AceAddon-3.0.lua:628: in function <...ddOns\DreamTweaks\libs\AceAddon-3.0\AceAddon-3.0.lua:621>
Locals: <none>
Here also is a link to the code for the cor.lua, actionbar.lua and map.lua file.
as you see I do have the code close to the same and it has the db = self.db.profile were it should be. So why am i getting this error. I'm very confused.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
http://www.wowace.com/paste/3901/
Thank you for all your help on this. I am still very new to coding and I learn from doing things trial by error not a book learner. I have the world of warcraft wrath Lua book and the Lua with world of warcraft addons. But there is not any good info on Ace3 in them. So again just want to thank you for baring with me on all of this.
- in Core.lua, you are not enabling nor disabling the module but only changing the settings, that's why OnDisable is never called,
- in ActionBars.lua, there is no OnInitialize that would fill the local db variable. This is what causes the errors.
By the way, in Core.lua your creating some global functions (StyleShapeshift, StylePet). This is wrong because it could cause conflicts with other addons using the same names. Moreover your global ActionButton_OnUpdate function will just overwrite Blizzard one and probably cause lots of trouble. Either make them local (if your only use them in Core.lua, or make them methods of your addon if you use them in other files).
You are also creating frame with name like Recount or Omen, this is very bad because these names are used to create global variables pointing to the frames. Your are probably overwriting the addons with these. Choose another names. Moreover, if you want your addon to properly detect these addons, you should list them in the OptionalDeps field of your TOC, so your addon does not get loaded before them.
Ok I added the Recount and Omen to the toc.
I moved all the code for the styling the buttons in with the code for the action bars Module.
Not sure what you mean on the "in Core.lua, you are not enabling nor disabling the module but only changing the settings" every exampel I have seen for the defalts only have the {Enable = true,} I however removed the {Disable = false,} that was there cus i was testing to see if that would do anything.
? " in ActionBars.lua, there is no OnInitialize that would fill the local db variable. This is what causes the errors."
If you haven't added "local" in front of "function" it wouldn't change anything.
According to what you pasted, in the set methods of the config options (in Core.lua), you are doing this :
This will never enable nor disable the ActionBars module by calling DreamTweaks:GetModule("ActionBars"):Enable() (or DreamTweaks:EnableModule("ActionBars") which is basically the same thing) and DreamTweaks:GetModule("ActionBars"):Disable(). So your modules are always enabled and never disabled.
You have to make up your mind : do you want to have several modules you can fully enable/disable and take advantage of this ? By example, disabling a module automatically disable all associated AceHook hooks and AceEvent listeners ; each module has its own set of event handlers. You could also add a :GetOptions() methods to each module and iterate them to build the main addon options. Each module can also have its own AceDB namespace by using self.db = DreamTweaks.db:RegisterNamespace(self.name, someDefaults). Etc...
If all you want is to split your code amongst several files and not the above fancy stuff, you do not need modules, just split the code, adding "public" methods to DreamTweaks so they are visible from every file.
Note that some fancy uses of modules aren't that easy to set up, especially the GetOptions part. And since you are still struggling with db and upvalues, the AceDB namespacing thing is probably a bit complicated too.
You can also make an AddOn-local table (visible ONLY to files in your AddOn) by doing this at the top of every file:
You can name these anything you like; I simply gave them those names to illustrate their usage.
From there, you can do things like:
This method would be visible throughout your AddOn, and nowhere else.
I think this is what I should do. I latter plan to add more Modules. If I added more modules wouldn't this be the better way to go. So I don't have to keep adding code to the core and config file. Or would I still have to add things for every module I add?
I have tried reading the Ace3 site pages but its not newbie friendly. Is there any other tutorials that are easier to understand?
that guide is also outdated and doesn't mention modules*
Anyway what Adirelle and Torhal just said should already give you the solution
Here is the new code.
http://www.wowace.com/paste/3915/
Here also is a link to the code for the cor.lua, actionbar.lua and map.lua file.
http://www.wowace.com/paste/3979/
as you see I do have the code close to the same and it has the db = self.db.profile were it should be. So why am i getting this error. I'm very confused.