View Single Post
05-02-12, 07:14 PM   #14
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,930
Okay, found a function in the wow files that I didn't see in wowprogramming and must have missed from wowpedia, and it all seems to work apart from your main requirement ... updating the MotD text automatically. Here's the code anyway. Hopefully Phanx can see what is wrong.

Lua Code:
  1. -- Get the localised addon information
  2. local addonName,addonData = ...
  3. addonData.MotD = ""
  4.  
  5. addonData.CheckGuildEvents = function()
  6.     addonData.NumGuildEvents = CalendarGetNumGuildEvents()
  7.     if ( addonData.NumGuildEvents == 0 ) then return end
  8.     local month, day, weekday, hour, minute, eventType, title, calendarType, textureName
  9.     for i = 1,addonData.NumGuildEvents do
  10.         month, day, weekday, hour, minute, eventType, title, calendarType, textureName = CalendarGetGuildEventInfo(i);
  11.         thisInfo = tostring(i) .. ": " .. title .. " at " .. GameTime_GetFormattedTime(hour, minute, true) .. " on " .. string.format(GUILD_NEWS_DATE, CALENDAR_WEEKDAY_NAMES[weekday], day, month)
  12.         -- GuildSetMOTD(thisInfo)               -- This works
  13.         if ( strlen(addonData.MotD) + strlen(thisInfo) > 128 ) then
  14.             -- GuildSetMOTD(addonData.MotD)     -- This doesn't work, wipes out old MotD but this doesn't appear in its place
  15.             break
  16.         else
  17.             addonData.MotD = string.format("%s\n%s",addonData.MotD, thisInfo)
  18.             -- GuildSetMOTD(addonData.MotD)     -- This doesn't work, wipes out old MotD but this doesn't appear in its place
  19.         end
  20.     end
  21.    
  22.     print(addonData.MotD, "(", strlen(addonData.MotD), ")")
  23.     GuildSetMOTD(addonData.MotD)                -- This doesn't work, wipes out old MotD but this doesn't appear in its place
  24.     --GuildSetMOTD("Testing testing 1 2 3")     -- This works
  25. end
  26.  
  27. local function OnEvent(self,event,arg1,arg2,arg3,arg4,arg5)
  28.     if ( event == "ADDON_LOADED" and arg1 == addonName ) then
  29.         if not IsAddOnLoaded("Blizzard_Calendar") then
  30.             LoadAddOn("Blizzard_Calendar")
  31.         end
  32.     elseif ( event == "PLAYER_ENTERING_WORLD" ) then
  33.         local weekday,month,day,year = CalendarGetDate()
  34.         local month, year, numDays, firstWeekday = CalendarGetMonth(0)
  35.         CalendarSetAbsMonth(month,year)    
  36.         OpenCalendar()
  37.     elseif ( event == "CALENDAR_UPDATE_GUILD_EVENTS" ) then
  38.         addonData.CheckGuildEvents()
  39.     elseif ( event == "CALENDAR_UPDATE_EVENT_LIST" ) then
  40.         addonData.CheckGuildEvents()
  41.     end
  42. end
  43.  
  44. local XGMotDFrame = CreateFrame("Frame","XGMotDFrame",UIParent)
  45. XGMotDFrame:SetScript("OnEvent", OnEvent)
  46. XGMotDFrame:RegisterEvent("ADDON_LOADED")
  47. XGMotDFrame:RegisterEvent("CALENDAR_UPDATE_GUILD_EVENTS")
  48. XGMotDFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
  49. XGMotDFrame:RegisterEvent("PLAYER_GUILD_UPDATE")
  50. XGMotDFrame:RegisterEvent("CALENDAR_UPDATE_EVENT_LIST")

CALENDAR_UPDATE_EVENT_LIST is triggered everytime you reload the UI and CALENDAR_UPDATE_GUILD_EVENTS is triggered when you first log in and when new guild events are added.
__________________


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-02-12 at 07:18 PM.
  Reply With Quote