local XXX_Old_ChatFrame_OnEvent;
function XXX_Options_OnLoad(self)
self.name = "XXX";
InterfaceOptions_AddCategory(self);
SLASH_XXX1 = "/XXX"
SlashCmdList["XXX"] = function()
InterfaceOptionsFrame_OpenToCategory("XXX");
end
if (XXX_Old_ChatFrame_OnEvent == nil) then
XXX_Old_ChatFrame_OnEvent = ChatFrame_OnEvent;
ChatFrame_OnEvent = XXX_ChatFrame_OnEvent;
end
end
function XXX_AddMessage(text, r, g, b, id, addToStart)
this:XXX_Old_AddMessage(text, r, g, b, id, addToStart);
end
function XXX_ChatFrame_OnEvent(self, event, ...)
XXX_Old_ChatFrame_OnEvent(self, event, ...)
if (this.XXX_Old_AddMessage == nil) then
this.XXX_Old_AddMessage = this.AddMessage;
this.AddMessage = XXX_AddMessage;
end
end
pls point me to some direction. other addons done exact same thing and it works...
i've tryed hook ChatFrame_MessageEventHandler, but it not filter everything in chat window.
I believe you want to replace this.XXX with self.XXX since you reference "self" in the function. "self" ~= "this" .... Doesn't matter which one you use, just be consistent.
several other addons use exact the same code as in initial post and it works. i'm unsure about .xml stuff.
Clearly they aren't as yours isn't working :P, are you sure everything is loading, stick print functions everywhere and try and work out whats going on.
i've tryed hook ChatFrame_MessageEventHandler, but it not filter everything in chat window.
I'm trying to make chat addon and have some troubles hooking AddMessage. I think problem is in .xml, but cant find it self. Please help.
xxx.xml
xxx.lua
ok, what happens is when
executed my chat silences.
pls point me to some direction. other addons done exact same thing and it works...
i've tryed hook ChatFrame_MessageEventHandler, but it not filter everything in chat window.
The only thing is affecting something if i call it that way:
it let pass all /say text, guid chat and combatlog, but all other messages isn't shown.
code in initial post is ok, other addons use code like this, with "func x(self, ...)" and hook to "this." and it working.
From my pov it look like my .lua script isnt assigned to frame correctly. what did i miss?
should be
XXX_AddMessage(self, text, r, g, b, id, addToStart)
as with <frame>:AddMessage()
<frame> is automatically passed as the first argument.
http://www.lua.org/manual/5.1/manual.html#2.5.8
no
http://www.wowwiki.com/API_ScrollingMessageFrame_AddMessage
anyway tryed AddMessage(self, ...) - isn't working.
several other addons use exact the same code as in initial post and it works. i'm unsure about .xml stuff.
Clearly they aren't as yours isn't working :P, are you sure everything is loading, stick print functions everywhere and try and work out whats going on.
If you just want to filter messages then you could use AddMessageEventFilter
and if that doesn't work then heres the code I use to hook the chatframe,
and finally
yes,
tbl.blah() is not the same as tbl:blah()
but tbl.blah(tbl) has the same functionality as tbl:blah()