Help with first mod
I am trying to build a very simple mod that tracks the debuff sleep from the Green Whelp Armor in the ACE framework. I am using the basic Welcome Home as a template. All the Ace options are working, but I can not get the Debuff to work. Thanks for any help. Here is my lua:
local L = AceLibrary("AceLocale-2.2"):new("greenwhelparmor")
local opts = {
type='group',
args = {
msg = {
type = 'text',
name = L["Message"],
desc = L["Sets the message to be displayed when your target is asleep."],
usage = L["<your message>"],
get = "GetMessage",
set = "SetMessage",
},
showInChat = {
type = 'toggle',
name = L["Show in Chat"],
desc = L["If set, your message will be displayed in the General chat window."],
get = "IsShowInChat",
set = "ToggleShowInChat",
},
showOnScreen = {
type = 'toggle',
name = L["Show on Screen"],
desc = L["If set, your message will be displayed on the screen near the top of the game field."],
get = "IsShowOnScreen",
set = "ToggleShowOnScreen"
},
},
}
greenwhelparmor = AceLibrary("AceAddon-2.0"):new("AceConsole-2.0", "AceEvent-2.0", "AceDB-2.0")
greenwhelparmor:RegisterChatCommand(L["Slash-Commands"], opts)
greenwhelparmor:RegisterDB("greenwhelparmorDB", "greenwhelparmorDBPC")
greenwhelparmor:RegisterDefaults("profile", {
message = L["Nap Time!"],
showInChat = false,
showOnScreen = true,
} )
function greenwhelparmor:OnEnable()
self:RegisterEvent("Aura_CHANGED")
end
function isTargetSleep()
if isTargetDead() then return false end;
if UnitIsFriend("player","target") then return false end;
return isTargetDebuffUp()
end;
function isUnitDebuffUp(sUnitname, sDebuffname)
local iIterator = 1
while (UnitDebuff(sUnitname, iIterator)) do
if (string.find(UnitDebuff(sUnitname, iIterator), sDebuffname)) then
return true
end
iIterator = iIterator + 1
end
return false
end
function isTargetDebuffUp()
return isUnitDebuffUp("target", "Sleep")
end;
function greenwhelparmor:Aura_CHANGED()
if isTargetSleep() 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
StopAttack();
end
end
function greenwhelparmor:GetMessage()
return self.db.profile.message
end
function greenwhelparmor:SetMessage(newValue)
self.db.profile.message = newValue
end
function greenwhelparmor:IsShowInChat()
return self.db.profile.showInChat
end
function greenwhelparmor:ToggleShowInChat()
self.db.profile.showInChat = not self.db.profile.showInChat
end
function greenwhelparmor:IsShowOnScreen()
return self.db.profile.showOnScreen
end
function greenwhelparmor:ToggleShowOnScreen()
self.db.profile.showOnScreen = not self.db.profile.showOnScreen
end
Last edited by Jiffiepop : 04-28-07 at 12:01 AM.
|