Question

I have a WoW/LUA script that I am attempting to start, but it seems to conflict with the Stubby addon, which is a part of the Auctioneer addon, I believe. Here is the message I receive:

Error occured in: Stubby Count: 1 Message: Error: Original call failed after running hooks for: ChatFrame_OnEvent Usage: SendChatMessage(text [,type] [,language] [,targetPlayer]) Debug:
(tail call): ? [string ":OnEvent"]:1: [string ":OnEvent"]:1

Now, the only thing that's happening in the conflicting addon is:

ChatFrame_AddMessageEventFilter("CHAT_MSG_PARTY", partyMsg)

The code within partyMsg is very simple as well:

local function partyMsg(msg,author,language,lineID,senderGUID)
  if (store ~= msg) then
    SendChatMessage(msg,"SAY",nil,nil);
  end
  store = msg;
end

Is this error due to two addons both trying to filter the chat frame? If so, how can this be done? It seems odd to me that Blizzard would have such a simple and yet important concept limited to one addon.

Was it helpful?

Solution

I think I see what happened here.

The reference you were using, Events/Communication, shows only the specific parameters for a particular event, regardless of context.

The context is usually an OnEvent handler.

The ChatFrame_AddMessageEventFilter function lets you use the chat frame's OnEvent handler instead of your own for chat frame events, and has well defined parameters for filters you add.

An OnEvent handler might look like:

function Foo_OnEvent(self, event, ...)

A 'ChatFrame' filter must look like this, for the first two parameters:

function Foo_ChatFrameFilter(self, event, msg, ...)

The ChatFrame filter is specific. For OnEvent however, you can make a Lua 'handler' that doesnt care about what frame it came from:

<OnEvent>
    MyEventHandler(event, ...)
</OnEvent>

OTHER TIPS

For the sake of completion, I will include the entire source of this addon:

local function partyMsg(someTable,msgType,msg,user,language,...)
  if (store ~= msg) then
      SendChatMessage(user .. " just said: ".. msg .. " using that sneaky " .. language .. " language.");
  end
  store = msg;
  return false;
end

ChatFrame_AddMessageEventFilter("CHAT_MSG_PARTY", partyMsg)
ChatFrame_AddMessageEventFilter("CHAT_MSG_PARTY_LEADER",partyMsg)

There were a couple issues with the original code:

1) I was using WoWWiki to get my information, and first, I read it incorrectly. lineID and senderGUID are not the 4th and 5th arguments. Then, beyond this, WoWWiki is incorrect on this page in general. The correct arguments are listed above in the source. The first argument, a table, I am unsure of its purpose. In any case, this code now works fully.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top