• 0

    posted a message on WelcomeHome - Your first Ace3 Addon
    Now I have another Problem.

    My Addon don't want save the Settings, when I change the both msg's (hmsg and vmsg).


    Here is my Core.lua
    WelcomeHome = LibStub("AceAddon-3.0"):NewAddon("WelcomeHome", "AceConsole-3.0", "AceEvent-3.0")
    
    ----------------------------------------
    -- Main
    ----------------------------------------
    
    local options = { 
        name = "WelcomeHome",
        handler = WelcomeHome,
        type = "group",
        args = {
        
            -- Enter Home Option
            hmsg = {
                type = "input",
                name = "At Home",
                desc = "Message when you enter your home.",
                usage = "<Your message>",
                get = "Get_hmsg",
                set = "Set_hmsg",
            },
            
            -- Leave Home Option
            vmsg = {
                type = "input",
                name = "Leave Home",
                desc = "Message if you leave your home.",
                usage = "<Your message>",
                get = "Get_vmsg",
                set = "Set_vmsg",
            },
            
            -- ShowInChat Option
            showInChat = {
                type = "toggle",
                name = "Show in Chat",
                desc = "Toggles the display of the message in the chat window.",
                get = "IsShowInChat",
                set = "ToggleShowInChat",
            },
            
            -- ShowOnChat Option
            showOnScreen = {
                type = "toggle",
                name = "Show on Screen",
                desc = "Toggles the display of the message on the screen.",
                get = "IsShowOnScreen",
                set = "ToggleShowOnScreen"
            },
            
        },
    }
    
    ----------------------------------------
    -- Default Settings
    ----------------------------------------
    
    local defaults = {
        profile = {
            message = "Welcome....!",    -- Message  = At Home
            message2 = "Good Bye....!",  -- Message2 = Leave Home
            showInChat = false,
            showOnScreen = true,
        },
    }
    
    ----------------------------------------
    -- Addon Standard
    ----------------------------------------
    
    function WelcomeHome:OnInitialize()
        -- Called when the addon is loaded
        self.db = LibStub("AceDB-3.0"):New("WelcomeHomeDB", defaults, "Default")
        
        LibStub("AceConfig-3.0"):RegisterOptionsTable("WelcomeHome", options)
        self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("WelcomeHome", "WelcomeHome")
        self:RegisterChatCommand("wh", "ChatCommand")
        self:RegisterChatCommand("welcomehome", "ChatCommand")
    end
    
    
    function WelcomeHome:OnEnable()																						
    		-- Called when the addon is enabled
    		self:Print("...loaded! .:: Version: Alpha 0.1 ::." )
    		self:RegisterEvent("ZONE_CHANGED")		  
    end
    
    ----------------------------------------
    -- Event Handler For Zone/Message
    ----------------------------------------
    
    function WelcomeHome:ZONE_CHANGED()
        -- When Home Entered
        if GetBindLocation() == GetSubZoneText() then
                if self.db.profile.showInChat then
                   self:Print(self.db.profile.message)
                end
    
                if self.db.profile.showOnScreen then
                    UIErrorsFrame:AddMessage(self.db.profile.message, 1.0, 1.0, 1.0, 5.0)       
                end
    				-- When Leave Home
            else if self.db.profile.showInChat then
                self:Print(self.db.profile.message2)
            end
            
            if self.db.profile.showOnScreen then
                UIErrorsFrame:AddMessage(self.db.profile.message2, 1.0, 1.0, 1.0, 5.0)       
            end
        end
    end
    
    ----------------------------------------
    -- Addon To BlizzAddons
    ----------------------------------------
    
    function WelcomeHome:ChatCommand(input)
        if not input or input:trim() == "" then
            InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
        else
            LibStub("AceConfigCmd-3.0").HandleCommand(WelcomeHome, "wh", "WelcomeHome", input)
        end
    end
    
    ----------------------------------------
    -- Display: hmsg/vmsg 
    ----------------------------------------
    
    -- At Home : hmsg
    
    function WelcomeHome:Get_hmsg(info)
        return self.db.profile.message
    end
    
    
    function WelcomeHome:Set_hmsg(info, newValue)
        self.db.profile.message = newValue
    end
    
    -- Leave Home : vmsg
    
    function WelcomeHome:Get_vmsg(info)
        return self.db.profile.message2
    end
    
    function WelcomeHome:Set_vmsg(info, newValue)
        self.db.profile.message2 = newValue
    end
    
    
    
    -- hmsg In Chat/On Screen
    
    function WelcomeHome:IsShowInChat(info)
        return self.db.profile.showInChat
    end
    
    
    function WelcomeHome:ToggleShowInChat(info, value)
        self.db.profile.showInChat = value
    end
    
    
    function WelcomeHome:IsShowOnScreen(info)
        return self.db.profile.showOnScreen
    end
    
    function WelcomeHome:ToggleShowOnScreen(info, value)
        self.db.profile.showOnScreen = value
    end
    
    -- vmsg In Chat/On Screen
    
    function WelcomeHome:IsShowInChat(info)
        return self.db.profile.showInChat
    end
    
    
    function WelcomeHome:ToggleShowInChat(info, value)
        self.db.profile.showInChat = value
    end
    
    
    function WelcomeHome:IsShowOnScreen(info)
        return self.db.profile.showOnScreen
    end
    
    function WelcomeHome:ToggleShowOnScreen(info, value)
        self.db.profile.showOnScreen = value
    end
    Posted in: Ace3
  • 0

    posted a message on WelcomeHome - Your first Ace3 Addon
    ZONE_CHANGED don't work for me. :confused:

    Core.lua
    WelcomeHome = LibStub("AceAddon-3.0"):NewAddon("WelcomeHome", "AceConsole-3.0", "AceEvent-3.0")
    
    function WelcomeHome:OnInitialize()																				
    		-- Called when the addon is loaded
        
    end
    
    function WelcomeHome:OnEnable()																						
    		-- Called when the addon is enabled
    		self:RegisterEvent("ZONE_CHANGED")		  
    end
    
    function WelcomeHome:ZONE_CHANGED()
    		self:Print("Du hast die Zone gewechselt!")
    end


    Lua Error-Message in WoW
    Message: Interface\AddOns\WelcomeHome\Core.lua:1: Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Cannot find a library instance of "AceEvent-3-0".
    Time: 10/25/11 10:38:53
    Count: 1
    Stack: [C]: ?
    ...ddOns\WelcomeHome\Libs\AceAddon-3.0\AceAddon-3.0.lua:210: in function `EmbedLibrary'
    ...ddOns\WelcomeHome\Libs\AceAddon-3.0\AceAddon-3.0.lua:192: in function `EmbedLibraries'
    ...ddOns\WelcomeHome\Libs\AceAddon-3.0\AceAddon-3.0.lua:159: in function `NewAddon'
    Interface\AddOns\WelcomeHome\Core.lua:1: in main chunk

    Locals: (*temporary) = "Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Cannot find a library instance of "AceEvent-3-0"."


    Edit: Problem Found

    I had in the embeds.xml this line wrong(line1):

    Wrong
    <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">


    Works
    <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
    ..\FrameXML\UI.xsd">
    Posted in: Ace3
  • To post a comment, please or register a new account.