well from the looks of it you havn't added AceDB-3.0 :P. 3.0 is implemented abit differently than 2.0 in that its not a mixin and because of that you need a few extra lines of code to get things like enable/disabling working but other than that it works quite similar.
Below is how I use it in my addons
local defaultDB = {
profile = {
enabled = true,
},
}
function addon:OnInitialize()
self.db = LibStub("AceDB-3.0"):New(self.name.."DB", defaultDB, "Default")
self:SetEnabledState(self.db.profile.enabled)
self.db.RegisterCallback(self, "OnProfileChanged")
self.db.RegisterCallback(self, "OnProfileReset", "OnProfileChanged")
end
function addon:OnEnable()
self.db.profile.enabled = true
end
function addon:OnDisable()
self.db.profile.enabled = false
end
function addon:OnProfileChanged()
local enabled = self.db.profile.enabled
if enabled ~= self:IsEnabled() then
if enabled then
self:Enable()
else
self:Disable()
end
else
if enabled then
self:OnEnable()
else
self:OnDisable()
end
end
end
So, is this the final code ? I'm sorry but for me here it's just a guessing game.
raidReRoute = LibStub("AceAddon-3.0"):NewAddon("raidReRoute", "AceConsole-3.0", "LibSink-2.0")
local defaultDB = {
profile = {
enabled = true,
},
}
function addon:OnInitialize()
self.db = LibStub("AceDB-3.0"):New(self.name.."DB", defaultDB, "Default")
self:SetEnabledState(self.db.profile.enabled)
self.db.RegisterCallback(self, "OnProfileChanged")
self.db.RegisterCallback(self, "OnProfileReset", "OnProfileChanged")
end
function addon:OnEnable()
self.db.profile.enabled = true
end
function addon:OnDisable()
self.db.profile.enabled = false
end
function addon:OnProfileChanged()
local enabled = self.db.profile.enabled
if enabled ~= self:IsEnabled() then
if enabled then
self:Enable()
else
self:Disable()
end
else
if enabled then
self:OnEnable()
else
self:OnDisable()
end
end
end
local addon = raidReRoute
addon:RegisterDB("RRRdb")
function addon:OnEnable()
self:SecureHook("RaidWarningFrame_OnEvent")
self:RegisterChatCommand( "/rrr", self.options )
end
function addon:RaidWarningFrame_OnEvent( orig , event, message, ... )
if event == "CHAT_MSG_RAID_WARNING" then
self:Pour( message ) --add [, red , blue , green , alpha ] to this to add color.
return RaidWarningFrame:Hide()
end
end
You have 2 functions with the same name (addon:OnEnable()), the last one will overwrite the 1st one. You also havn't embeded AceHook-3.0 which means self:SecureHook won't work and the slashcommand wouldn't do anything because there are no options and the database doesn't really do alot either.
Anyway, the code below should work for what you want it to do:
raidReRoute = LibStub("AceAddon-3.0"):NewAddon("raidReRoute", "AceConsole-3.0", "AceHook-3.0", "LibSink-2.0")
local addon = raidReRoute
local defaultDB = {
profile = {
enabled = true,
sinkOptions = {},
},
}
addon.options = {
type = "group",
handler = addon,
args = {
enable = {
name = "Enable",
desc = "Enables / disables the addon",
type = "toggle",
set = function(key, value)
if value then
addon:Enable()
else
addon:Disable()
end
end,
get = "IsEnabled",
},
}
}
function addon:OnInitialize()
self.db = LibStub("AceDB-3.0"):New(self.name.."DB", defaultDB, "Default")
self:SetEnabledState(self.db.profile.enabled)
self.db.RegisterCallback(self, "OnProfileChanged")
self.db.RegisterCallback(self, "OnProfileReset", "OnProfileChanged")
self:SetSinkStorage(self.db.profile.sinkOptions)
self:RegisterChatCommand( "/rrr", self.options)
self.options.args.sinkOptions = self:GetSinkAce3OptionsDataTable()
end
function addon:OnEnable()
self.db.profile.enabled = true
self:SecureHook("RaidWarningFrame_OnEvent")
end
function addon:OnDisable()
self.db.profile.enabled = false
self:UnhookAll()
end
function addon:OnProfileChanged()
local enabled = self.db.profile.enabled
if enabled ~= self:IsEnabled() then
if enabled then
self:Enable()
else
self:Disable()
end
else
if enabled then
self:OnEnable()
else
self:OnDisable()
end
end
end
function addon:RaidWarningFrame_OnEvent(orig , event, message, ...)
if event == "CHAT_MSG_RAID_WARNING" then
self:Pour(message) --add [, red , blue , green , alpha ] to this to add color.
return RaidWarningFrame:Hide()
end
end
Hello all!
I write similar addon, but i have problem with libsink-2.0.
I want add options for redirect different types of messages in different output area. http://ace.pastey.net/107723
Below is how I use it in my addons
http://www.wowace.com/wiki/AceDB-3.0
Anyway, the code below should work for what you want it to do:
Ok, but how ?
so, use self: for the methods from those libraries
I write similar addon, but i have problem with libsink-2.0.
I want add options for redirect different types of messages in different output area.
http://ace.pastey.net/107723
Thanks for response
Im inspired this thread