• 0

    posted a message on db (a nil value) error help.
    Quote from Ketho
    Not sure if that would be it, but you're redefining the db upvalue another 2 times on line 52 and 1509

    I don't know much about modules though, or if it's supposed to be like that :s


    Not seeing the db in line 52 and 1509. Here is the thing it gives me no error for my action bars module but it dos for all other modules. There all however set up the same way so it makes no sense.

    Core.lua
    http://www.wowace.com/paste/3999/

    ActionBars
    http://www.wowace.com/paste/4000/

    Map
    http://www.wowace.com/paste/4001/
    Posted in: Lua Code Discussion
  • 0

    posted a message on db (a nil value) error help.
    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.

    Quote:
    Message: Interface\AddOns\DreamTweaks\modules\Minimap.lua:1 25: attempt to index field 'db' (a nil value)
    Time: 09/23/11 23:31:35
    Count: 1
    Stack: Interface\AddOns\DreamTweaks\modules\Minimap.lua:1 25: 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.

    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.
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    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.

    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.
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    Ok I think I got it, but it still wont disable the modules.

    Here is the new code.
    http://www.wowace.com/paste/3915/
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    Quote from Adirelle
    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?
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    Quote from Adirelle
    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."
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    Here is all of my code minus the other modules since there all pretty much set the same as the one for the Action bars.

    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.
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    Quote from gamemaster128
    If you want to print variables, you have to actually specify them in the print command.

    print("Text", var1, var2, var3)


    All is coming up nil,nil,nil but nothing on the "OnDisable".

    Quote from Ketho
    http://www.lua.org/manual/5.1/manual.html#pdf-print
    http://www.wowpedia.org/API_print
    In my original post, I should have mentioned you can also just add whatever stuff you want to know, in it
    function ActionBars:OnInitialize()
    	self.db = DreamTweaks.db
    	db = self.db.profile;
    	print("Hello OnInitialize!", [COLOR="Red"]db.ActionBars.Enable[/COLOR])
            -- do stuff
    end


    Nothing shows in chat, but I get this error.

    Message: Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:231: attempt to index upvalue 'db' (a nil value)
    Time: 09/07/11 22:15:52
    Count: 1
    Stack: Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:231: in function <Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:230>
    (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: self = <table> {
     SetDefaultModuleLibraries = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:383
     Enable = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:315
     NewModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:256
     EnableModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:348
     modules = <table> {
     }
     GetModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:231
     IterateEmbeds = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:458
     IsModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:238
     baseName = "DreamTweaks"
     defaultModuleLibraries = <table> {
     }
     OnDisable = <function> defined @Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:244
     OnInitialize = <function> defined @Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:230
     SetEnabledState = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:440
     moduleName = "ActionBars"
     enabledState = true
     ApplyConfig = <function> defined @Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:34
     OnEnable = <function> defined @Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:28
     Refresh = <function> defined @Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:225
     GetName = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:300
     defaultModuleState = true
     Disable = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:330
     IterateModules = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:453
     name = "DreamTweaks_ActionBars"
     SetDefaultModulePrototype = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:425
     IsEnabled = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:467
     orderedModules = <table> {
     }
     SetDefaultModuleState = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:403
     DisableModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:366
    }
    (*temporary) = <function> defined @Interface\FrameXML\RestrictedInfrastructure.lua:116
    (*temporary) = "Hello OnInitialize!"
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = "attempt to index upvalue 'db' (a nil value)"
    db = nil
    DreamTweaks = <table> {
     SetDefaultModuleLibraries = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:383
     Enable = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:315
     RegisterChatCommand = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceConsole-3.0\AceConsole-3.0.lua:85
     EnableModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:348
     modules = <table> {
     }
     GetModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:231
     IterateEmbeds = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:458
     defaultModuleLibraries = <table> {
     }
     optionsFrame = <unnamed> {
     }
     UnregisterChatCommand = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceConsole-3.0\AceConsole-3.0.l


    Quote from Adirelle
    So the module is never disabled.

    Add some print("db.ActionBars.Enable=", db.ActionBars.Enable) in various places, including the configuration get and set functions.


    Same nothing shows in chat but I get this error.

    Message: Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:229: attempt to index upvalue 'db' (a nil value)
    Time: 09/07/11 22:18:21
    Count: 1
    Stack: Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:229: in function <Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:228>
    (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: self = <table> {
     SetDefaultModuleLibraries = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:383
     Enable = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:315
     NewModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:256
     EnableModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:348
     modules = <table> {
     }
     GetModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:231
     IterateEmbeds = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:458
     IsModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:238
     baseName = "DreamTweaks"
     defaultModuleLibraries = <table> {
     }
     OnDisable = <function> defined @Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:241
     OnInitialize = <function> defined @Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:228
     SetEnabledState = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:440
     moduleName = "ActionBars"
     enabledState = true
     ApplyConfig = <function> defined @Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:33
     OnEnable = <function> defined @Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:28
     Refresh = <function> defined @Interface\AddOns\DreamTweaks\Modules\ActionBars.lua:223
     GetName = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:300
     defaultModuleState = true
     Disable = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:330
     IterateModules = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:453
     name = "DreamTweaks_ActionBars"
     SetDefaultModulePrototype = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:425
     IsEnabled = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:467
     orderedModules = <table> {
     }
     SetDefaultModuleState = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:403
     DisableModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:366
    }
    (*temporary) = <function> defined @Interface\FrameXML\RestrictedInfrastructure.lua:116
    (*temporary) = "db.ActionBars.Enable="
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = "attempt to index upvalue 'db' (a nil value)"
    db = nil
    DreamTweaks = <table> {
     SetDefaultModuleLibraries = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:383
     Enable = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:315
     RegisterChatCommand = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceConsole-3.0\AceConsole-3.0.lua:85
     EnableModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:348
     modules = <table> {
     }
     GetModule = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:231
     IterateEmbeds = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceAddon-3.0\AceAddon-3.0.lua:458
     defaultModuleLibraries = <table> {
     }
     optionsFrame = <unnamed> {
     }
     UnregisterChatCommand = <function> defined @Interface\AddOns\DreamTweaks\Libs\AceConsole-3.0\AceConsole-3.0
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    Ok I am not getting any value of the setting info, I don't think.

    function ActionBars:OnEnable()
    	print("Hello OnEnable!")
            -- do stuff
    end
    

    function ActionBars:ApplyConfig()
    	print("Hello ApplyConfig!")
            -- do stuff
    end
    

    function ActionBars:OnInitialize()
    	print("Hello OnInitialize!")
            -- do stuff
    end
    

    function ActionBars:OnDisable()
    	print("Hello OnDisable!")
            -- do stuff
    end
    


    All show up in the chat frame but the "OnDisable".
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    Quote from Adirelle
    Add some print statements in "OnInitialize", "OnEnable", "OnDisable" and "ApplyConfig" to see what is called (and what is the value of the setting) ; it might help you. You are probably having issue not with the module but with your options.


    Ok sorry for being such a Nub. But what do I have it say, look for. In other words how do I do the print?
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    Errrg getting so frustrated with myself. I can't figure this stuff out.

    "Torhal" I tried your suggestion and still same thing I have to do a reload if I deselect the enable box in the GUI. But if it is disabled and I turn it on it dos it with no reload.

    "Adirelle" I changed that part of the code to. I see no difference but who knows (I don't).
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    Dos the "if not then return end" not work for action bar modules with Ace3?
    I did what you said and still it will set my module if enabled but if I disable it it dos nothing till I do a reload.

    ActionBars = {
    	name = "ActionBars",
    	type = "group",
    	order = 1,
    	args = {
    		Enable={
    			name="Enable",
    			desc="Enables / disables the addon",
    			type="toggle",
    			order = 1,
    			set = function(info, val)
    			db.ActionBars.Enable = val
    				if val then
    					DreamTweaks:EnableModule("ActionBars")
    				else
    					DreamTweaks:DisableModule("ActionBars")
    				end
    			end,
    			get = function(info) return db.ActionBars.Enable end,
    		},
    


    function ActionBars:OnEnable()
    	self:ApplyConfig()
    end
    
    function ActionBars:ApplyConfig()
    	db = self.db.profile
            --more code
            if not self.db.profile.ActionBars.Enable == true then return end
    end
    
    function ActionBars:Refresh()
    	db = self.db.profile
    	self:ApplyConfig()
    end
    
    function ActionBars:OnInitialize()
    	self.db = LibStub("AceDB-3.0"):New("DreamTweaksDB", defaults, "Default");
    	db = self.db.profile;
    
    	-- Do not automatically enable the addon if disabled in config
    	self:SetEnabledState(self.db.profile.ActionBars.Enable)
    
    	self.db = DreamTweaks.db
    	self.db.RegisterCallback(self,"OnProfileChanged","Refresh")
    	self.db.RegisterCallback(self,"OnProfileCopied","Refresh")
    	self.db.RegisterCallback(self,"OnProfileReset","Refresh")
    end
    
    function ActionBars:OnDisable()
    	self:ApplyConfig()
    end
    
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    Ok if i select the enable option in the gui it turns on but if i deselect it it dos nothing till i do a reload.

    ActionBars = {
    	name = "ActionBars",
    	type = "group",
    	order = 1,
    	args = {
    		Enable={
    		name="Enable",
    		desc="Enables / disables the addon",
    		type="toggle",
    		order = 1,
    		set = function(info, val)
    		db.ActionBars.Enable = val
    		DreamTweaks:GetModule("ActionBars"):ApplyConfig()
    		end,
    		get = function(info) return db.ActionBars.Enable end,
    		},
    	},
    

    local defaults = {
    	profile = {
    		ActionBars = {
    			Enable = true,
    		},
    

    function ActionBars:ApplyConfig()
    	if self.db.profile.ActionBars.Enable then
    --more code
    	else
    		if not self.db.profile.ActionBars.Enable then return end
    	end
    
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    O one other question. How can I put a option to enable or disable the module and if disabled the options in the ingame GUI don't show? Is this possible to do?
    Posted in: Lua Code Discussion
  • 0

    posted a message on NewModule help?
    Sweat thank you. :grin:

    One of these days I will understand all this. I have only working with Ace3 for 2 weeks, It's so alien to me. Then again I have not been coding for very long and been teaching my self with the help of other addon creators.
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.