Thread Tools Display Modes
06-15-10, 09:40 AM   #1
Fodaro
A Cyclonian
 
Fodaro's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 42
Getting a list of pending events

Hello everyone,

I'm starting to work on a mod with a friend. The plan is to have a 'Welcome screen' appear when you log into the game, reminding you of what you were doing, transmutes you want to do, guild stuff, etc. The plan is to have two panes which will show different information. The user will be able to choose which two panes they want to see on login.

That's all well and good, but on the Guild Information pane I want to show a list of guild events that the player has been invited to, but not yet responded to. I believe CalendarGetNumPendingInvites gives the number of them, and CalendarGetFirstPendingInvite gives the first one, but after that I can't find out how to get the rest.

I suppose I could loop through all the events in the calendar and check each one, or just have a button to say "X invites pending..." but there must be a better way, mustn't there?

Thanks,
__________________
Fodaro
(Main: Fodaro-Bronzebeard (EU))
Author of CharNote and Consolid8
  Reply With Quote
06-15-10, 10:21 AM   #2
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
but after that I can't find out how to get the rest.
I suppose I could loop through all the events in the calendar and check each one
Hope you don't mind me quoting yourself; but you answered your own question.
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.
  Reply With Quote
06-15-10, 11:06 AM   #3
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
Maybe an example would be more helpful.

Personally I'd probably not use the 2nd function you mentioned (CalendarGetFirstPendingInvite) as it only returns the event index of the current day you're checking and I'm guessing it just does the same check you'll be doing anyway.
You could also get rid of CalendarGetNumDayEvents and just check if the event title is nil (no more events)

You won't need to "open" the events unless you want to check another player's status. So it's enough calling CalendarGetDayEvent()

Code:
-- Events for the next 7 days
CheckNextSevenDays = function()
    local day = select(3, CalendarGetDate())
    local month = 0 -- calendar use offset by default so 0 is current, -1 previous, +1 is next
    for d=1,7 do
        if day > 31 then -- I don't know the function name to retrieve how many days there is a month
            month=month + 1
            day = 1
        end
        local num = CalendarGetNumDayEvents(month, day)
        for e=1,num do
            local title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus, invitedBy, difficulty, inviteType, sequenceIndex, numSequenceDayss = CalendarGetDayEvent(month, day, e)
            --[[
            CALENDAR_INVITESTATUS_INVITED      = 1
            CALENDAR_INVITESTATUS_ACCEPTED     = 2
            CALENDAR_INVITESTATUS_DECLINED     = 3
            CALENDAR_INVITESTATUS_CONFIRMED    = 4
            CALENDAR_INVITESTATUS_OUT          = 5
            CALENDAR_INVITESTATUS_STANDBY      = 6
            CALENDAR_INVITESTATUS_SIGNEDUP     = 7
            CALENDAR_INVITESTATUS_NOT_SIGNEDUP = 8
            CALENDAR_INVITESTATUS_TENTATIVE    = 9
            --]]
            print(inviteStatus .." : ".. title)
            -- This printed 1: Midsummer Fire Festival as well so remember to check the types
        end
        day = day + 1
    end
end
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.
  Reply With Quote
06-16-10, 09:57 AM   #4
Fodaro
A Cyclonian
 
Fodaro's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 42
OK, thanks v6o, I'll try that.
__________________
Fodaro
(Main: Fodaro-Bronzebeard (EU))
Author of CharNote and Consolid8
  Reply With Quote
06-17-10, 01:56 PM   #5
Fodaro
A Cyclonian
 
Fodaro's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 42
Strange... the script doesn't print anything. After a bit of messing around, it appears that CalendarGetNumDayEvents is returning 0, or sometimes 1 or 2. Either way, there doesn't appear to be any relation to the number of events on that day. Maybe I'll just show a count of pending invites.
__________________
Fodaro
(Main: Fodaro-Bronzebeard (EU))
Author of CharNote and Consolid8
  Reply With Quote
06-17-10, 02:21 PM   #6
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
Are you running this script before calendar is filled with events?

Are you testing my script as I posted it or did you edit something?

Are you completely sure the month and day is correct with offsets as I explained in a comment in the script?

If it still doesn't work why don't you just drop the function and do as I said you could in my previous post (same post as the script)
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.

Last edited by v6o : 06-17-10 at 02:34 PM. Reason: changed `date´ to `day´
  Reply With Quote
06-17-10, 02:30 PM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,925
I played with the calendar a few weeks back to check something for someone. Let me see what I ended up doing and if it ended up working rofl. I think there is a certain function/event that has to be used or triggered before you can get event information from the calendar.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
06-17-10, 02:56 PM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,925
Oh and v60. This is the function you would need to get the number of days per month

month, year, numDays, firstWeekday = CalendarGetMonth([monthOffset])
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
06-17-10, 04:35 PM   #9
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,925
Okay, as I discovered when I played with this before, some of the functions operate differently when you first log in and when you do a reloading of the UI. I haven't figured out why that is though so cannot comment further on it.

Here are a couple of images of my results though :

Images 1 and 2 are using PLAYER_ENTERING_WORLD to Initialise Data
Image 1 is after using a reloadUI
Image 2 is after a character relog

Images 3 and 4 are using VARIABLES_LOADED to update information that may not have been available.
Image 3 is after using a reloadUI
Image 4 is after a character relog

As you can see an extra event is triggered on a character relog that isn't triggered on a reloading of the UI but I suspect it will also trigger when you get an invite while you are in game. That is something I can't test for personally as I am usually the one that sets up the guilds events rofl and these tests are on characters on the same account and I only have 1 account. But it will give you some idea as to how you can progress with it.

Anyway here's the code I used in this test. It doesn't handle the checking of x days ahead but with the function I mentioned earlier to test for the number of days and the functions I use in here to get information for a specific day it should put you in the right direction to tweak them to cater for checking x days ahead.

Code:
local weekday, month, day, year, monthOffset
local numEvents, numInvites
local title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus, invitedBy, difficulty, inviteType
local name, level, className, classFileName, inviteStatus, modStatus, inviteIsMine, inviteType2
local eventTypes,weekdayNames,monthNames
local currentEvent,currentQuery
local pendingInvite
local updateEventListCount = 0

local function RespondTo_CalendarUpdatePendingInvites()

	print("Getting Number of Pending Invites")
	numInvites = CalendarGetNumPendingInvites()
	print("You have ", numInvites, " you have not responded to")
	if ( numInvites == 0 ) then return end
	
	print("Getting Number of events for day/monthoffset : ", day,monthOffset)
	numEvents = CalendarGetNumDayEvents(monthOffset, day)
	print("Number of events/monthOffset = ", numEvents, monthOffset)
	if ( numEvents == 0 ) then return end
	
	print("Events you need to be aware of are as follows : ");
	for index = 1,numEvents do
		title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus, invitedBy, difficulty, inviteType = CalendarGetDayEvent(monthOffset, day, index)
		print("Title:", title, "Time:", hour..":"..minute, "Calendar Type:", calendarType, "Sequence Type:",sequenceType, "Event Type:", eventType, "Invite Status:", inviteStatus, "Invited By:", invitedBy, "Difficulty:", difficulty, "Invite Type:", inviteType);
		if ( calendarType == GUILD_EVENT or calendarType == GUILD_ANNOUNCEMENT or calendarType == PLAYER ) then
			print("This is a guild event or announcement or a player created event")
			if ( inviteStatus == 1 or inviteStatus == 8 or inviteStatus == 5 ) then		
				print("You have been invited or have not signed up or the invite is out");
			end
		end
	end
end

local function QueryCalendar()

	print("Querying Calendar")

	OpenCalendar();

	print("Generating list of months and weekdays and event types")
	monthNames = { CalendarGetMonthNames() }
	weekdayNames = { CalendarGetWeekdayNames() }	
	eventTypes = { CalendarEventGetTypes() }

	weekday, month, day, year  = CalendarGetDate()
	print("CalendarGetDate returned: ", weekday,"(",weekdayNames[weekday],")", day, month, "(",monthNames[month],")", year)
	print("Setting calendar to month/year : ", month, "(",monthNames[month],")", year)
	CalendarSetAbsMonth(month,year)
	monthOffset = 0
	print("Getting Number of events for day/monthoffset : ", day,monthOffset)
	numEvents = CalendarGetNumDayEvents(monthOffset, day)
	print("Number of events/monthOffset = ", numEvents, monthOffset)

	RespondTo_CalendarUpdatePendingInvites()
end


local function OnEvent(self,event,...)

	print(event,...)
		
	if event == "ADDON_LOADED" then
		if arg1 == addonName then
			if not IsAddOnLoaded("Blizzard_Calendar") then
				LoadAddOn("Blizzard_Calendar")
			end
			self:UnregisterEvent(event)
		end
	elseif event == "VARIABLES_LOADED" then
		QueryCalendar()
		self:UnregisterEvent(event)
	elseif event == "PLAYER_ENTERING_WORLD" then
		QueryCalendar()
		self:UnregisterEvent(event);
	elseif event == "CALENDAR_UPDATE_PENDING_INVITES" then
		RespondTo_CalendarUpdatePendingInvites()
	end
	
end


local XCalendarFrame = CreateFrame("Frame","XCalendarFrame",UIParent)
XCalendarFrame:SetScript("OnEvent",OnEvent)
XCalendarFrame:RegisterEvent("ADDON_LOADED")
XCalendarFrame:RegisterEvent("VARIABLES_LOADED")
XCalendarFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
XCalendarFrame:RegisterEvent("CALENDAR_UPDATE_PENDING_INVITES")
Attached Thumbnails
Click image for larger version

Name:	WoWScrnShot_061710_231412.jpg
Views:	626
Size:	302.1 KB
ID:	4420  Click image for larger version

Name:	WoWScrnShot_061710_231547.jpg
Views:	614
Size:	309.2 KB
ID:	4421  Click image for larger version

Name:	WoWScrnShot_061710_231953.jpg
Views:	619
Size:	297.7 KB
ID:	4422  Click image for larger version

Name:	WoWScrnShot_061710_232147.jpg
Views:	608
Size:	300.0 KB
ID:	4423  

__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
06-17-10, 05:38 PM   #10
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
The way around it is towait a while and then fire OpenCalendar(). This function will not show the frame but load the events from the server....at least first time it's called.

When you do a /reload the events are already loaded if you've called OpenCalendar() once during your session.

Calling OpenCalendar() during loading progress only resulted in events not showing up at all on calendar.


Image 1 is on login and image 2 is /reload
(...and 18=2 means 18th, 2 events)
Attached Thumbnails
Click image for larger version

Name:	login.png
Views:	621
Size:	120.6 KB
ID:	4424  Click image for larger version

Name:	reload.png
Views:	619
Size:	11.5 KB
ID:	4425  
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.

Last edited by v6o : 06-17-10 at 06:02 PM.
  Reply With Quote
06-29-10, 09:21 AM   #11
Fodaro
A Cyclonian
 
Fodaro's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 42
OK, I've modified your function, v6o, to avoid using CalendarGetNumDayEvents, and it's working fine when I run it after I've opened the calendar or called OpenCalendar.

lua Code:
  1. function CheckNextSevenDays()
  2.     print("Welcome Screen Guild Page getting calendar information:")
  3.  
  4.     local day = select(3, CalendarGetDate())
  5.     local month = 0 -- calendar use offset by default so 0 is current, -1 previous, +1 is next
  6.     local numDays = select(3, CalendarGetMonth(month))
  7.     for d=1,7 do
  8.         if day > numDays then
  9.             month = month + 1
  10.             day = 1
  11.             numDays = select(3, CalendarGetMonth(month))
  12.         end
  13.         local safety = 100
  14.         local i = 1
  15.         while true do
  16.             local title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus,
  17.                 invitedBy, difficulty, inviteType, sequenceIndex, numSequenceDayss = CalendarGetDayEvent(month, day, i)
  18.             if title then
  19.                 if eventType ~= 0 then -- Ignore holidays, call to arms, fishing contests etc.
  20.                     print(inviteStatus.." : "..title.." (type "..eventType..")")
  21.                 end
  22.                 i = i + 1
  23.             else -- no more events
  24.                 break
  25.             end
  26.            
  27.             if safety == 0 then
  28.                 print("SAFETY!")
  29.                 break
  30.             else
  31.                 safety = safety - 1
  32.             end
  33.             day = day + 1
  34.         end
  35.     end
  36. end

I've worked out that CALENDAR_UPDATE_EVENT_LIST fires once its ready, but I'm not sure when to call OpenCalendar, as I want my frame to appear when the player logs in. I've tried PLAYER_ENTERING_WORLD and PLAYER_LOGIN.

Sorry, but I can't work out what your screenshots mean, Xrystal. The second one (with PLAYER_ENTERING_WORLD on relog) seems to be working, but when are you calling OpenCalendar?

Thanks for your help guys,
__________________
Fodaro
(Main: Fodaro-Bronzebeard (EU))
Author of CharNote and Consolid8
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Getting a list of pending events

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off