Originally Posted by Fayren
Here's how I hooked.
Code:
local oldSendChatMessage;
oldSendChatMessage = SendChatMessage;
Here's what my function does.
Code:
function SendChatMessage(text, type, language, target)
if (pirate_talk_on == 1) then
text = piratespeak(text);
end
oldSendChatMessage(text, type, language, target);
end
My code does not call oldSendChatMessage or SendChatMessage anywhere except what you see here. I know that it gets call multiple times though because I've looked at the output or I've done debug print outs.
Am I hooking wrong?
If it would help I can email the file or post it here if that's not considered rude. I know some forums look down on people posting whole files into posts.
|
It looks good to me, except for one little thing that you should do. Use this:
Code:
function SendChatMessage(text, type, language, target, ...)
if (pirate_talk_on == 1) then
text = piratespeak(text);
end
oldSendChatMessage(text, type, language, target, ...);
end
This way, if SendChatMessage() is ever changed to allow for additional parameters in the future, it will still be hooked correctly. In fact, in this sense, you could actually write the following, since you only care about "text" in your addon:
Code:
function SendChatMessage(text, ...)
if (pirate_talk_on == 1) then
text = piratespeak(text);
end
oldSendChatMessage(text, ...);
end
And it will function equivalently. But, is what you have "wrong?" No. How about you go to
http://wowi.pastey.net and paste up your code there, and I'll try running it to see how it runs. Alternatively, you could zip up your addon (TOC and all) and attach it here so someone could take a look at it.