Thread Tools Display Modes
05-30-10, 04:29 PM   #1
drdextro
A Deviate Faerie Dragon
Join Date: May 2010
Posts: 10
Choosing the right calendar event

I am writing modifying an addon for our guild to give penalties to people who dont attend.

I want to check the ppl who are online versus the accepted ppl in a calendar event.

My script is working but there is 1 problem when there are mulitple events i have to select the right one. The following piece of code should give me a list of the events on this day. But it gives me mulitple times the same event. Can anyone help me with this.

Updated:
Code:
function EventInformationList()
local weekday, month, day  = CalendarGetDate()
local numEvents = CalendarGetNumDayEvents(0, day)
	rr_Print("--Calendarevents--", rr_GetPrintDest()) --My own print function
for i = 1, numEvents do
local title, creator, hour, minute
		CalendarOpenEvent(0, day, i)
		title, _, creator, _, _, _, _, _, _, _, _, hour, minute = CalendarGetEventInfo()
		rr_Print(i .. ". " .. title .. ": " .. creator .. "   " .. hour .. ":" .. minute, rr_GetPrintDest()) 
		CalendarCloseEvent()
end
end
Example output:

--Calendarevents--
1. Test: Drdextro 12:00
2. Test: Drdextro 12:00
3. Test: Drdextro 12:00

constantly the same event, eventough i closed the event

Last edited by drdextro : 05-30-10 at 05:09 PM.
  Reply With Quote
05-30-10, 05:00 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Let me guess - it always returns info about the last event? You have this:
Code:
CalendarOpenEvent(0, day, numEvents)
which will always open the calendar event with the index of whatever numEvents equals (ex. 3 events, it always will look at 3)

instead of this
Code:
CalendarOpenEvent(0, day, i)
where i will increment by 1 until it reaches the value of numEvents.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
05-30-10, 05:05 PM   #3
drdextro
A Deviate Faerie Dragon
Join Date: May 2010
Posts: 10
no .. i just copied it wrong .. i did have the sentence you typed


i edited the first post .. it still gives the same result

Last edited by drdextro : 05-30-10 at 05:08 PM.
  Reply With Quote
05-30-10, 05:15 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Well, then, I'm not sure why it wouldn't be working... Everything else seems to be in order... Though I haven't worked with that API.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
05-30-10, 05:33 PM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
Hmm, interesting. Just tried it myself and one single event created and it printed it twice for some reason. However, there is also a game Event listed on the same day so could be linked to that in which case, perhaps the same problem.

Ah, it seems to be only printing the last event read. As if it has read in the whole days transactions and decided not to look at them rofl.

Created in this order
Event 1 : test For Addon - me - 10pm
Event 2 : Another test - me - 9pm

Shown on Calendar for day
Event 1 : Another test - me - 9pm
Event 2 : test For Addon - me - 10pm
Strangelthorn Fishing Event - blizz - 2pm

Printout when only Event 1 Created :
test For Addon - me - 22 0
test For Addon - me - 22 0

Printout when Event 2 Created :
Another Test - me - 22 0
Another Test - me - 22 0
Another Test - me - 22 0
__________________


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

Last edited by Xrystal : 05-30-10 at 06:26 PM.
  Reply With Quote
05-30-10, 05:56 PM   #6
drdextro
A Deviate Faerie Dragon
Join Date: May 2010
Posts: 10
So it must be the API thats disfunctioning.

I am also posting it on the wow forums maby a blizzposter knows the answer or acknowledges the disfunction.

Last edited by drdextro : 05-30-10 at 06:01 PM.
  Reply With Quote
05-30-10, 06:25 PM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
I did notice some events that exist for the calendar but they don't always trigger the way you would think.

CALENDAR_OPEN_EVENT - Fires when the player begins viewing or editing details of a calendar event ( args = "HOLIDAY" or "GUILD" or "PLAYER" )

This works for manual selecting but not programmed selection

CALENDAR_CLOSE_EVENT - Fires when the player ends viewing or editing details of a calendar event

Didn't seem to trigger at all

CALENDAR_UPDATE_EVENT - Fires when details become available for the event being viewed or edited

Didn't seem to trigger at all

CALENDAR_UPDATE_EVENT_LIST - Fires when the list of events visible on the calendar changes

Fired when I opened the calendar.

So I put my code in there and this time it seems to have cycled through all events and left the window for the last one open.


Testing what happens if I pre-load the Blizzard_Calendar addon.
__________________


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
05-30-10, 07:17 PM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
Aha, found another function that looks to be what you need to use.

title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus, invitedBy, difficulty, inviteType = CalendarGetDayEvent(monthOffset, day, eventIndex)

That returns the correct information based on that eventIndex

Ah .. got it working on log in .. I have Blizzard_Calendar as a required dependancy and the following lua code. It listed each event in order with whatever information I asked to be displayed Now you can go have some fun with your functionality

Code:
local addonName, addonData = ...

local weekday, month, day, year, monthOffset
local numEvents
local title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus, invitedBy, difficulty, inviteType
local eventTypes

local XCalendarFrame = CreateFrame("Frame","XCalendarFrame",UIParent)

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
		weekday, month, day, year  = CalendarGetDate()
		CalendarSetAbsMonth(month,year)
		monthOffset = 0
		numEvents = CalendarGetNumDayEvents(monthOffset, day)
		eventTypes = { CalendarEventGetTypes() }
		print(weekday,month,day,monthOffset,numEvents)
		
		for eventIndex = 1, numEvents do
			title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus, invitedBy, difficulty, inviteType = CalendarGetDayEvent(monthOffset, day, eventIndex)
			print(title, hour..":"..minute, calendarType, eventTypes[eventType], invitedBy, difficulty);
		end	
	end
	
end

XCalendarFrame:SetScript("OnEvent",OnEvent)
XCalendarFrame:RegisterEvent("ADDON_LOADED")
XCalendarFrame:RegisterEvent("VARIABLES_LOADED")
__________________


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
05-31-10, 04:32 AM   #9
drdextro
A Deviate Faerie Dragon
Join Date: May 2010
Posts: 10
Thanks!!

Its working.. now i can conitinue my addon.
  Reply With Quote
05-31-10, 10:09 AM   #10
drdextro
A Deviate Faerie Dragon
Join Date: May 2010
Posts: 10
I made list with your supplied code. The list is clickable and supplies the right index. When you click the an event ( the same as the real calendar ). The following code wil be executed:

Code:
function rr_SelectCalendarEvent(link)
	        local index = string.sub(link,7)
		weekday, month, day, year  = CalendarGetDate()
		CalendarSetAbsMonth(month,year)
		monthOffset = 0	
		CalendarOpenEvent(monthOffset, day, index)
end
This should open the event. Upon CalendarOpenEvent() .. 2 events are triggerd

CALENDAR_OPEN_EVENT
and
CALENDAR_ACTION_PENDING

I now want to get information from the event. So after opening i want to use for example CalendarGetNumPendingInvites(). But if i use this function upon the event "CALENDAR_OPEN_EVENT" the information isnt available.

Code:
if (event == "CALENDAR_OPEN_EVENT") then 
    	rr_OpenSelectedEvent()
		return
    end
Code:
function rr_OpenSelectedEvent()
     local numInvites =  CalendarGetNumPendingInvites()
     print(numInvites)
     CalendarCloseEvent()
end

My question is now.. how do i know that the calendar information is ready to use.
  Reply With Quote
05-31-10, 10:48 AM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Did you try it using the second event? CALENDAR_ACTION_PENDING
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
05-31-10, 10:52 AM   #12
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
Also try these that I recall triggered when opening :

CALENDAR_UPDATE_INVITE_LIST - Fires when the invite/signup list is updated for the event being viewed or edited

CALENDAR_UPDATE_EVENT - Fires when details become available for the event being viewed or edited
__________________


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
05-31-10, 11:15 AM   #13
drdextro
A Deviate Faerie Dragon
Join Date: May 2010
Posts: 10
When iam checking with event trace i get:

CALENDAR_ACTION_PENDING
then 0.3455 sec later
CALENDAR_OPEN_EVENT
CALENDAR_ACTION_PENDING


i cant see any of these CALENDAR_UPDATE_INVITE_LIST / CALENDAR_UPDATE_EVENT

NOTE:
The first CALENDAR_ACTION_PENDING has and arg1 with value nil and the second has no arg1

Last edited by drdextro : 05-31-10 at 11:27 AM.
  Reply With Quote
05-31-10, 12:25 PM   #14
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
Hmm are you trying to use CalendarGetNumPendingInvites to get your pending invites or the number of people that have pending invites on events you set up ?

If the first then, okay that should work if you haven't accepted or refused yet. If the last then its the wrong function for what you want.

wowprogramming.com shows this as the description for that function
CalendarGetNumPendingInvites - Returns the number of calendar invitations to which the player has yet to respond

This is the one for listing the number of invites
CalendarEventGetNumInvites - Returns the number of characters on the selected calendar event's invite/signup list

Then you can use this in an internal loop to get information on each invitee
name, level, className, classFileName, inviteStatus, modStatus, inviteIsMine, inviteType2 = CalendarEventGetInvite(inviteIndex)



As to those events .. rofl can't get them all to happen now, might have been pure luck rofl.

This is what my VARIABLES_LOADED event block looks like now with these new functions running, minus the print commands that is rofl:

Code:
weekday, month, day, year  = CalendarGetDate()
CalendarSetAbsMonth(month,year)
monthOffset = 0
numEvents = CalendarGetNumDayEvents(monthOffset, day)
eventTypes = { CalendarEventGetTypes() }
for eventIndex = 1, numEvents do
	title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus, invitedBy, difficulty, inviteType = CalendarGetDayEvent(monthOffset, day, eventIndex)
	numInvites = CalendarEventGetNumInvites()			
	for inviteIndex = 1, numInvites do
		name, level, className, classFileName, inviteStatus, modStatus, inviteIsMine, inviteType2 = CalendarEventGetInvite(inviteIndex)
	end
end
__________________


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

Last edited by Xrystal : 05-31-10 at 12:46 PM.
  Reply With Quote
05-31-10, 05:06 PM   #15
drdextro
A Deviate Faerie Dragon
Join Date: May 2010
Posts: 10
I have tested youre code this was my result

Calendar
3 events with random ppl

Code:
function EventInformation()
weekday, month, day, year  = CalendarGetDate()
CalendarSetAbsMonth(month,year)
monthOffset = 0
numEvents = CalendarGetNumDayEvents(monthOffset, day)
eventTypes = { CalendarEventGetTypes() }
for eventIndex = 1, numEvents do
	title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus, invitedBy, difficulty, inviteType = CalendarGetDayEvent(monthOffset, day, eventIndex)
	numInvites = CalendarEventGetNumInvites()			
	for inviteIndex = 1, numInvites do
		name, level, className, classFileName, inviteStatus, modStatus, inviteIsMine, inviteType2 = CalendarEventGetInvite(inviteIndex)
						if(inviteStatus == 2 or inviteStatus == 4) then
			print(eventIndex .. ". " .. name .. " " .. level .. " " .. inviteStatus)
			end
	end
end
I made a print function and filtered out only the accepts and confirmed

This is the output i get
[01:01:29] 1. Helenija 80 4
[01:01:29] 1. Moshid 80 4
[01:01:29] 1. Debke 80 2
[01:01:29] 1. Staffkeeper 80 2
[01:01:29] 2. Helenija 80 4
[01:01:29] 2. Moshid 80 4
[01:01:29] 2. Debke 80 2
[01:01:29] 2. Staffkeeper 80 2
[01:01:29] 3. Helenija 80 4
[01:01:29] 3. Moshid 80 4
[01:01:29] 3. Debke 80 2
[01:01:29] 3. Staffkeeper 80 2

It seems to stay on the first calendar event
  Reply With Quote
05-31-10, 05:08 PM   #16
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
grumbles, admittedly those last functions were only tested on the one event *slaps head*. I'll do some other tests next time Im able.
__________________


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
05-31-10, 05:10 PM   #17
drdextro
A Deviate Faerie Dragon
Join Date: May 2010
Posts: 10
hahah :P .. sorry to cause the troubles


PS:
My goal is to select a specific event to get the info from. Instead of the for-loop looping the events i am suppling the index nr. i want.
This works but only once.

Last edited by drdextro : 05-31-10 at 05:28 PM.
  Reply With Quote
05-31-10, 05:58 PM   #18
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
Ah gotcha. Well, I've been lucky so far figuring this out so who knows .. I might manage to track it down. But it might be like the guild bank functions and events. Not quite as functional as you would think rofl.
__________________


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-01-10, 02:25 AM   #19
drdextro
A Deviate Faerie Dragon
Join Date: May 2010
Posts: 10
I have been trying some things. There seems to be something interesting going on.

The moment you manualy open a calendar event in de wow calendar and then pick your event. It takes the information from your last opent event.

I tried to replicated this event by CalendarOpenEvent() but this function takes time and it doesnt give you an Event when the data is actually availble
  Reply With Quote
06-01-10, 06:05 AM   #20
drdextro
A Deviate Faerie Dragon
Join Date: May 2010
Posts: 10
I found a temporary solution .. I now start the frame with the names from the CalendarEventViewFrame in the blizzard calendar itself.

Its not what i would like but its fair enough. ( for now )
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Choosing the right calendar event


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