View Single Post
02-14-14, 06:44 PM   #19
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
I'm pretty sure that I've found a good way of getting everything I need now, using Ravagernl's suggestion.

Lua Code:
  1. local frame;
  2. for i = 1, NUM_CHAT_FRAMES do
  3.   frame = _G["ChatFrame"..i];
  4.   frame:HookScript("OnEvent", function(self, event, ...)
  5.     self.lastEvent = (self.isDocked and MONITORED_EVENTS[event]) and event;
  6.   end);
  7.   hooksecurefunc(frame, "AddMessage", function(self, message, r, g, b, ...)
  8.     if (not self.lastEvent) then return; end
  9.     -- do my thing...
  10.   end);
  11. end


That way I have a guarantee that the message will actually be displayed. It should be reliable because self.lastEvent will always be obtained immediately before AddMessage gets called.

Cheers all
__________________
__________________

Last edited by Aanson : 02-14-14 at 06:56 PM.
  Reply With Quote