Still not working :|
AuroraLib = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceConsole-2.0", "AceDB-2.0", "AceHook-2.1", "AceDebug-2.0")
function AuroraLib:OnInitialize()
-- Called when the addon is loaded
PetHappinessFrame = PetHappinessFrame or CreateFrame("Messageframe", "AuroraLibPetHappinessFrame", UIParent)
PetHappinessFrame:SetWidth(150)
PetHappinessFrame:SetHeight(70)
PetHappinessFrame:SetPoint("TOPLEFT", 400, -500)
PetHappinessFrame:SetTimeVisible(6) --how long it will stay visible
PetHappinessFrame:SetFadeDuration(.5) --how long it will spend fading out
PetHappinessFrame:SetFont("Fonts\\FRIZQT__.ttf", 24, "OUTLINE")
PetHappinessFrame:RegisterForDrag("LeftButton")
PetHappinessFrame:SetScript("OnDragStart", function() this:StartMoving() end)
PetHappinessFrame:SetScript("OnDragStop", function() this:StopMovingorSizing() end)
PetHappinessFrame:AddMessage("Pet is Content!", 1,1,1)
PetHappinessFrame.background = PetHappinessFrame:CreateTexture("Interface\\Tooltips\\UI-Tooltip-Background", "AuroraLibPetHappinessFrameBackground")
PetHappinessFrame.background:SetTexture(1, 1, 1, 0.25)
PetHappinessFrame.background:SetWidth(150)
PetHappinessFrame.background:SetHeight(70)
PetHappinessFrame.background:SetPoint("TOP", "AuroraLibPetHappinessFrame", "CENTER", 0, 20)
hide()
local slashOptions = {
type = 'group',
args={
happy = {
type='execute',
name="happy",
desc="Shows the happiness and loyalty of your pet",
func = function() self:showHappiness() end
}
}
}
self:RegisterChatCommand({ "/aurlib"}, slashOptions)
-- self:RegisterEvent("CHAT_MSG_PET_INFO", "petUpdate")
self:RegisterEvent("UNIT_HAPPINESS", "showHappiness")
AuroraLib:SystemMessage("Loaded!")
end
function AuroraLib:OnEnable()
-- Called when the addon is enabled
end
function AuroraLib:SystemMessage(msg)
DEFAULT_CHAT_FRAME:AddMessage("|cFFFFC0CBAuroraLib|cFFFFFFFF: "..msg)
end
function AuroraLib:OnDisable()
-- Called when the addon is disabled
end
function AuroraLib:COMBAT_LOG_EVENT()
-- arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20
AuroraLib:SystemMessage("Combat log changed")
end
function AuroraLib:showHappiness()
happiness, damagePercentage, loyaltyRate = GetPetHappiness()
if not happiness then
DEFAULT_CHAT_FRAME:AddMessage("No Pet")
hide()
else
local happy = ({"Unhappy", "Content", "Happy"})[happiness]
local loyalty = loyaltyRate > 0 and "gaining" or "losing"
hide()
if happy ~= "Happy" then
if happy == "Content" then
PetHappinessFrame:AddMessage("Pet is " .. happy .. "!", 1, 1, 0)
else
PetHappinessFrame:AddMessage("Pet is " .. happy .. "!", 1, 0, 0)
end
show()
end
end
end
function hide()
PetHappinessFrame.background:SetTexture(1, 1, 1, 0)
if PetHappinessFrame:IsVisible() then
PetHappinessFrame:Hide()
end
end
function show()
PetHappinessFrame.background:SetTexture(1, 1, 1, 0.25)
if not PetHappinessFrame:IsVisible() then
PetHappinessFrame:Show()
end
end