Hello,
i am new to addon programming and i have more or less 2 similiar addons now (one own and one is just a dummy test project i found that shows how to create addon settings)
I use the same Libraries for both (LibAddon2.0)
addon.txt
Code:
## Title: MountFeedTimer Reloaded
## Description: Shows the remaining time until you can feed your mount again!
## APIVersion: 100015
## Author: Lagenia
## Version: 1.0
## DependsOn:
## OptionalDependsOn: LibAddonMenu-2.0, LibStub
## SavedVariables: MountFeedTimerSavedVariables
lib\LibStub\LibStub.lua
lib\LibAddonMenu-2.0\LibAddonMenu-2.0.lua
lib\LibAddonMenu-2.0\controls\panel.lua
lib\LibAddonMenu-2.0\controls\submenu.lua
lib\LibAddonMenu-2.0\controls\button.lua
lib\LibAddonMenu-2.0\controls\checkbox.lua
lib\LibAddonMenu-2.0\controls\colorpicker.lua
lib\LibAddonMenu-2.0\controls\custom.lua
lib\LibAddonMenu-2.0\controls\description.lua
lib\LibAddonMenu-2.0\controls\dropdown.lua
lib\LibAddonMenu-2.0\controls\editbox.lua
lib\LibAddonMenu-2.0\controls\header.lua
lib\LibAddonMenu-2.0\controls\slider.lua
lib\LibAddonMenu-2.0\controls\texture.lua
MountFeedTimerReloadedMenu.lua
MountFeedTimerReloaded.lua
MountFeedTimerReloadedMenu.lua
Code:
if MFT == nil then MFT = {} end
function MFT.MakeMenu()
local menu = LibStub("LibAddonMenu-2.0")
local set = MFT.settings
local panel = {
type = "panel",
name = "MountFeedTimer",
displayName = "Mount Feed Timer Reloaded",
author = "Lagenia"
version = "" .. MFT.version,
}
local options = {
{
type = "header",
name = "Settings"
},
{
type = "checkbox",
name = "Unlock Windows",
tooltip = "Toggle lock on/off",
getFunc = function() return set.lock end,
setFunc = function(value)
set.lock = value
end,
},
{
type = "dropdown",
name = "Display when",
tooltip = "Display when?",
choices = {"Always", "Hide in menus","Menus only", "Timer < 1 hour", "Toggle keybind"},
getFunc = function() return set.Hide_Type end,
setFunc = function(value)
set.Hide_Type = value
end,
warning = "Keybind doesn't work with french client (german?)"
},
}
menu:RegisterAddonPanel("MountFeedTimer_Reloaded", panel)
menu:RegisterOptionControls("MountFeedTimer_Reloaded", options)
end
and the MountFeedTimerReloaded.lua
Code:
local em = GetEventManager()
if MFT == nil then MFT = {} end
MFT.name = "MountFeedTimer"
MFT.version = "1.0"
MFT.settings = {}
MFT.defaults = {
lock = true,
Hide_Type = "Menus only",
}
function MFT.Initialize(event, addonName)
if addonName ~= MFT.name then return end
em:UnregisterForEvent("MountFeedTimerInitialize", EVENT_ADD_ON_LOADED)
MFT.settings = ZO_SavedVars:New("MountFeedTimerSavedVariables",1,nil,MFT.defaults)
ZO_CreateStringId("SI_BINDING_NAME_MountFeedTimer_Reloaded_TOGGLE", "Toggle Window")
MFT.MakeMenu()
end
em:RegisterForEvent(MFT.name, EVENT_ADD_ON_LOADED, function(...) MFT.Initialize(...) end)