View Single Post
09-21-12, 04:47 PM   #23
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
Well with the following block of code I managed to get hold of your Guild Rep and XP and Events. But like you said access to the Calendar information seems to only trigger when you physically open the calendar. Then it carries out your code for the respective events.

XGIDB_Data is just my saved variables data for this test addon. Play about with it as you will. I only spent a couple of hours on it so may have missed some possibilities out.

Lua Code:
  1. local addonName, addonData = ...
  2.  
  3. local addonLoaded = false
  4. local calendarLoaded = false
  5. local guildLoaded = false
  6. local calendarOpened = false
  7.  
  8. XGIDB_Data = {}
  9. XGIDB_Data.index = 0
  10.  
  11. local function OnEvent(self,event,...)
  12.     local args = { ... }
  13.  
  14.     print(event,...)
  15.  
  16.     XGIDB_Data.index = XGIDB_Data.index or 0
  17.     XGIDB_Data.index = XGIDB_Data.index + 1
  18.  
  19.     XGIDB_Data[XGIDB_Data.index] = {}
  20.     XGIDB_Data[XGIDB_Data.index][event] = {}
  21.     XGIDB_Data[XGIDB_Data.index][event]["Arguments"] = {}
  22.     for i,v in pairs(args) do
  23.         tinsert(XGIDB_Data[XGIDB_Data.index][event]["Arguments"],v)
  24.     end
  25.  
  26.     if ( event == "ADDON_LOADED" and args[1] == addonName) then
  27.         if not IsAddOnLoaded("Blizzard_Calendar") then
  28.             LoadAddOn("Blizzard_Calendar")
  29.         end
  30.         addonLoaded = true
  31.     end
  32.  
  33.     if ( event == "ADDON_LOADED" and args[1] == "Blizzard_Calendar") then
  34.         calendarLoaded = true
  35.     end
  36.  
  37.     if ( event == "UPDATE_FACTION") then
  38.         local numFactions = GetNumFactions()
  39.         XGIDB_Data[XGIDB_Data.index]["Factions"] = {}
  40.         XGIDB_Data[XGIDB_Data.index]["Factions"].Count = numFactions
  41.         for index = 1,numFactions do
  42.             local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(index)
  43.             if ( name == "Guild" ) then
  44.                 XGIDB_Data[XGIDB_Data.index]["GuildRep"] =
  45.                 {
  46.                     description = description,
  47.                     standing = standingID,
  48.                     hasRep = hasRep,
  49.                     value = barValue,
  50.                     max = barMax,
  51.                 }
  52.             end
  53.         end
  54.     end
  55.  
  56.     if ( event == "GUILD_ROSTER_UPDATE") then
  57.         QueryGuildXP()
  58.         QueryGuildEventLog()
  59.     end
  60.  
  61.  
  62.     if ( event == "GUILD_XP_UPDATE" ) then
  63.         local currentXP, nextLevelXP, dailyXP, maxDailyXP, weeklyXP, totalXP, isUncapped = UnitGetGuildXP("player")
  64.         XGIDB_Data[XGIDB_Data.index]["GuildXP"] =
  65.         {
  66.             CurrentXP = currentXP,
  67.             DailyXP = dailyXP,
  68.             WeeklyXP = weeklyXP,
  69.             TotalXP = totalXP,
  70.         }
  71.     end
  72.  
  73.     if ( event == "GUILD_EVENT_LOG_UPDATE" ) then
  74.         local numEvents = GetNumGuildEvents()
  75.         XGIDB_Data[XGIDB_Data.index]["GuildEvents"] = {}
  76.         XGIDB_Data[XGIDB_Data.index]["GuildEvents"]["Number of Events"] = numEvents
  77.         for index = 1,numEvents do
  78.             local type, player1, player2, rank, year, month, day, hour = GetGuildEventInfo(index)
  79.             tinsert(XGIDB_Data[XGIDB_Data.index]["GuildEvents"],
  80.             {
  81.                 Index = index,
  82.                 Type = type,
  83.                 Source = player1,
  84.                 Target = player2,
  85.                 Rank = rank,
  86.                 Year = year,
  87.                 Month = month,
  88.                 Day = day,
  89.                 Hour = hour,
  90.             }
  91.             )
  92.         end
  93.     end
  94.  
  95.     if ( event == "PLAYER_GUILD_UPDATE") then
  96.         if ( args[1] == "player" ) then
  97.             GuildRoster()
  98.         end
  99.     end
  100.  
  101.     if ( event == "CALENDAR_UPDATE_GUILD_EVENTS") then
  102.         local numEvents = CalendarGetNumGuildEvents()
  103.         XGIDB_Data[XGIDB_Data.index]["GuildCalendarEvents"] = {}
  104.         XGIDB_Data[XGIDB_Data.index]["GuildCalendarEvents"]["Number of Events"] = numEvents
  105.         for index = 1,numEvents do
  106.             local month, day, weekday, hour, minute, eventType, title, calendarType, textureName = CalendarGetGuildEventInfo(index)
  107.             tinsert(XGIDB_Data[XGIDB_Data.index]["GuildCalendarEvents"],
  108.             {
  109.                 Index = index,
  110.                 CalendarType = calendarType,
  111.                 EventType = eventType,
  112.                 Title = title,
  113.                 Month = month,
  114.                 Day = day,
  115.                 Hour = hour,
  116.                 Weekday = weekday,
  117.             }
  118.             )
  119.         end
  120.     end
  121.  
  122.     if ( event == "CALENDAR_UPDATE_EVENT_LIST") then
  123.         local weekday,month,day,year = CalendarGetDate()
  124.         local numEvents = CalendarGetNumDayEvents(0, day)
  125.         XGIDB_Data[XGIDB_Data.index]["CalendarEvents"] = {}
  126.         XGIDB_Data[XGIDB_Data.index]["CalendarEvents"]["Number of Events"] = numEvents
  127.         for index = 1,numEvents do
  128.             local title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus, invitedBy, difficulty, inviteType = CalendarGetDayEvent(0, day, index)
  129.             tinsert(XGIDB_Data[XGIDB_Data.index]["CalendarEvents"],
  130.             {
  131.                 Index = index,
  132.                 CalendarType = calendarType,
  133.                 EventType = eventType,
  134.                 Title = title,
  135.                 Month = month,
  136.                 Day = day,
  137.                 Hour = hour,
  138.                 Weekday = weekday,
  139.             }
  140.             )          
  141.         end
  142.     end
  143.  
  144.     if addonLoaded and calendarLoaded and not calendarOpened then
  145.         local weekday,month,day,year = CalendarGetDate()
  146.         local month, year, numDays, firstWeekday = CalendarGetMonth(0)
  147.         CalendarSetAbsMonth(month,year)    
  148.         OpenCalendar()
  149.         calendarOpened = true
  150.     end
  151.  
  152. end
  153.  
  154. local frame = CreateFrame("Frame","XGIFrame",UIParent)
  155. frame:RegisterEvent("ADDON_LOADED")
  156. frame:RegisterEvent("UPDATE_FACTION")
  157. frame:RegisterEvent("PLAYER_GUILD_UPDATE")
  158. frame:RegisterEvent("GUILD_ROSTER_UPDATE")
  159. frame:RegisterEvent("GUILD_XP_UPDATE")
  160. frame:RegisterEvent("GUILD_EVENT_LOG_UPDATE")
  161. frame:RegisterEvent("CALENDAR_UPDATE_GUILD_EVENTS")
  162. frame:RegisterEvent("CALENDAR_UPDATE_EVENT_LIST")
  163. frame:SetScript("OnEvent",OnEvent)
__________________


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