Well, you have a glaringly obvious syntax error that is almost certainly causing your error (an extra "end" at the end of your event handler) and your code formatting suffers from inconsistent indentation that makes it hard to read. Try this:
Code:
local addon = CreateFrame("Frame")
addon:RegisterEvent("ADDON_LOADED")
addon:SetScript("OnEvent", function(self, event, name)
if name ~= "Blizzard_TimeManager" then return end
TimeManagerClockButton:SetPoint("BOTTOM", Minimap, 0, 16)
TimeManagerClockButton:SetHeight(8)
TimeManagerClockButton:SetWidth(30)
local clockFrame, clockTime = TimeManagerClockButton:GetRegions()
clockFrame:Hide()
clockTime:SetFontObject(SystemFont_Tiny)
if CalendarGetNumPendingInvites() > 0 then
clockTime:SetTextColor(0, 1, 0)
else
clockTime:SetTextColor(1, 1, 1)
end
end)
However, as someone else pointed out, this will only set the clock text color once when you log in. It won't update when you receive an invite later.
Add this to your TOC:
Code:
## LoadOnDemand: 1
## LoadWith: Blizzard_TimeManager
Then your Lua can just look like this:
Code:
TimeManagerClockButton:SetPoint("BOTTOM", Minimap, 0, 16)
TimeManagerClockButton:SetHeight(8)
TimeManagerClockButton:SetWidth(30)
local clockFrame, clockTime = TimeManagerClockButton:GetRegions()
clockFrame:Hide()
clockTime:SetFontObject(SystemFont_Tiny)
local addon = CreateFrame("Frame")
addon:RegisterEvent("PLAYER_LOGIN")
addon:RegisterEvent("CALENDAR_UPDATE_PENDING_INVITES")
addon:SetScript("OnEvent", function(self, event)
if CalendarGetNumPendingInvites() > 0 then
clockTime:SetTextColor(0, 1, 0)
else
clockTime:SetTextColor(1, 1, 1)
end
end)