• 0

    posted a message on Private table in addons
    I've seen in a lot of addons the following code.
    local private = select(2, ...)
    I remember reading somewhere that each .lua file is given a list in the variable argument list (...) and this code fills private with a table that contains all the addon information.

    My question is what exactly is the format of the list. For example, what would select (1, ...) or select(3, ...) return? If my thinking is correct the later would return nil while the former would be the addon name as seen by the WoW client.

    I know I could code this up and test it myself, and it looks like I answered the question myself, but I'm hoping that the addon developement community can set my thinking straight and possibly show me and other beginning addon developers how to access this information.
    Posted in: Need Help?
  • 0

    posted a message on GetAddon() fail issue
    I found the issue while closely examining the load order. I misspelled the LRM.lua file in the TOC.
    Posted in: AddOn HELP!
  • 0

    posted a message on GetAddon() fail issue
    I've been struggling to figure out the error message I have been getting when my addon is loading. Any help would be appreciated.

    When I log in or do a /reload I get an error message from AceAddon-3.0's GetAddon() saying it can't find an addon named "LRM". The addon will load with no error if I comment out Config.lua, and I'm fairly certain would load fine if I moved everything into one file. I'm not using a load manager, and I have Ace3 embedded with the addon.

    Below is my TOC, and the two lua files I have.

    --- LRM.toc ---
    ## Interface: 30300
    ## X-Curse-Packaged-Version: r42
    ## X-Curse-Project-Name: Lore Master
    ## X-Curse-Project-ID: loremstr
    ## X-Curse-Repository-ID: wow/loremstr/mainline
    
    #@non-alpha@
    ## Title:      LRM
    ## Title-frFR: LRM
    ## Title-deDE: LRM
    ## Title-koKR: LRM
    ## Title-esMX: LRM
    ## Title-ruRU: LRM
    ## Title-zhCN: LRM
    ## Title-esES: LRM
    ## Title-zhTW: LRM
    #@end-non-alpha@
    #@alpha@
    ## Title: LRM - debug version
    #@end-alpha@
    
    #@non-alpha@
    ## Notes:      LRM is an addon that tracks a players completed quests and shows a percentage of completed quests by zone.
    ## Notes-frFR: LRM est un add-on qui piste les quêtes complétées d'un joueur et montre un pourcentage des quêtes complètes par zone.
    ## Notes-deDE: LRM is an addon that tracks a players completed quests and shows a percentage of completed quests by zone.
    ## Notes-koKR: LRM is an addon that tracks a players completed quests and shows a percentage of completed quests by zone.
    ## Notes-esMX: LRM is an addon that tracks a players completed quests and shows a percentage of completed quests by zone.
    ## Notes-ruRU: LRM is an addon that tracks a players completed quests and shows a percentage of completed quests by zone.
    ## Notes-zhCN: LRM is an addon that tracks a players completed quests and shows a percentage of completed quests by zone.
    ## Notes-esES: LRM is an addon that tracks a players completed quests and shows a percentage of completed quests by zone.
    ## Notes-zhTW: LRM is an addon that tracks a players completed quests and shows a percentage of completed quests by zone.
    #@end-non-alpha@
    #@alpha@
    ## Notes: Latest alpha version of LMR
    #@end-alpha@
    
    ## Author: scisto
    ## X-Credits: Blubibulga
    
    ## Version: 1.0.42
    ## X-Revision: 42
    ## X-Date: 2009-12-18T19:39:32Z
    
    ## X-Category: Quests & Leveling, Achievements
    ## X-Localizations: enUS, frFR, zhCN, zhTW, deDE, koKR, esES, esMX, ruRU
    
    ## DefaultState: Enabled
    ## SavedVariables: LRMDB2
    
    #@no-lib-strip@
    # Libraries
    embeds.xml
    #@end-no-lib-strip@
    
    # Localizations
    local.xml
    
    LMR.lua
    Config.lua
    


    --- LRM.lua ---
    -- Localize Lua globals
    local _G = getfenv(0)
    
    local tostring = _G.tostring
    local tonumber = _G.tonumber
    local pairs, ipairs = _G.pairs, _G.ipairs
    
    -- Localize AddOn namespace
    local LibStub = _G.LibStub
    
    local MODNAME = "LRM"
    local addon   = LibStub("AceAddon-3.0"):NewAddon(MODNAME, "AceConsole-3.0", "AceEvent-3.0")
    local L       = LibStub("AceLocale-3.0"):GetLocale(MODNAME)
    
    -- Init functions
    function addon:OnInitialize()  -- Called when the addon is loaded
       local defaults = {
          char = {
             -- current zone; used for knowing when to load/unload zone quest data
             zone = "",
             -- current continent; used for knowing when to load/unload continent quest data
             -- also unloads zone quest data
             continent = "",
          },
       }
       
       self.db = LibStub("AceDB-3.0"):New("LRMDB2", defaults)
       if not self.db then
          self:Print("Error: Database not loaded correctly. Please exit out of WoW.")
          return
       end
       
       local version = GetAddonMetadata("LRM", "Version")
       version = string.gusb(version, "@project.revision@", "SVN")
       self.version = version
       
       self:SetupOptions()
    
       -- Register the slash commands
       self:RegisterChatCommand("lrm", "ChatCommand")
       self:RegisterChatCommand("loremaster", "ChatCommand")
    end
    
    function addon:OnEnable()  -- Called when the addon is enabled; Registers events and pre-loads certain variables
       -- Register zone events
       self:RegisterEvent("ZONE_CHANGED_NEW_AREA")
    end
    
    function addon:ZONE_CHANGED_NEW_AREA()  -- tracks which zone and continent the player is in
       -- save the new zone
       if self.db.char.zone ~= GetZoneText() then
          self.db.char.zone = GetZoneText()
          self.db.char.continent = addon:GetContinent(self.db.char.zone)
       end
    
       -- debug --
       self:Print("Current zone is " .. self.db.char.zone)
       self:Print("Current continent is " .. self.db.char.continent)
    end
    
    function addon:GetContinent(zone)  -- 
       local conts = {GetMapContinents()}
        
       for idx,cont in ipairs(conts) do
          -- debug --
          self:Print("idx = " .. idx .. "    cont = " .. cont)
            
          local zones = {GetMapZones(idx)}
          for i,z in ipairs(zones) do
             -- debug --
             self:Print("  i = " .. i .. "   z = " .. z)
                
             if zone == z then
                return cont
             end
          end
       end
    end
    
    function addon:ChatCommand(input)
        if not input or input:trim() == "" then
            InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
        else
            LibStub("AceConfigCmd-3.0").HandleCommand(addon, "lrm", "loremaster", input)
        end
    end
    


    --- Config.lua ---
    local MODNAME      = "LRM"
    local addon        = LibStub("AceAddon-3.0"):GetAddon(MODNAME)
    local L            = LibStub("AceLocale-3.0"):GetLocale(MODNAME)
    
    local AceConfig    = LibStub("AceConfig-3.0")
    local AceConfigReg = LibStub("AceConfigReqistry-3.0")
    local AceConfigDia = LibStub("AceConfigDialog-3.0")
    
    local modularOptions = {}
    
    -- Get the profile information from SavedVariables
    local function getProfiles()
       return LibStub("AceDBOptions-3.0"):GetOptionsTable(addon.db)
    end
    
    local options
    
    local function fullOptions()
       if not options then
          options = {
             type = "group",
             name = MODNAME,
             args = {
                general = {
                   order = 1,
                   type  = "group",
                   name  = L["General"],
                   desc  = L["GEN_OPTS_DESC"],
                   args  = {
                      header1 = {
                         order = 10,
                         type  = "header",
                         name  = L["General Options"],
                      },
                      version = {
                         order = 11,
                         type  = "description",
                         name  = _G.GAME_VERSION_LABEL .. ": " .. addon.version .. "\n",
                      },
                   },
                },
             },
          }
       end
    
       for k,v in pairs(modularOptions) do
          options.args[k] = (type(v) == "function") and v() or v
       end
       
       return options
    end
    
    function addon:SetupOptions()
       AceConfigReq:RegisterOptionsTable(MODNAME, fullOptions)
       self.optionsFrame = AceConfigDialog:AddToBlizOptions(MODNAME, nil, nil, "general")
       
       -- register the module options
       self:RegisterModuleOptions("Profiles", getProfiles(), L["Profile"])
       
       -- add about panel to Bliz options
       if LibStub:GetLibrary("LibAboutPanel", true) then
          self.optionsFrame["About"] = LibStub:GetLibrary("LibAboutPanel").new(MODNAME, MODNAME)
       else
          self.Print("LibAboutPanel not loaded")
       end
    end
    
    function addon:RegisterModuleOptions(name, optionsTable, displayName)
       modularOptions[name] = optionsTable
       self.optionsFrame[name] = AceConfigDialog:AddToBlizOptions(MODNAME, displayName, MODNAME, name);
    end
    
    Posted in: AddOn HELP!
  • To post a comment, please or register a new account.