Thread Tools Display Modes
06-19-09, 04:47 PM   #1
yayofelipe
A Kobold Labourer
Join Date: Jun 2009
Posts: 1
Get Message

How i can do a addon get any message and save in a table for use it?

sorry for my english
  Reply With Quote
06-19-09, 05:18 PM   #2
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
To read chat messages, you need to

1. Create a frame if you don't already have one.
2. Register the frame for the chat event (or events) that you want to watch.
2a. See http://www.wowwiki.com/Events/Communication for a list.
2b. See http://www.wowwiki.com/Events if you need more information on the event system.
3. Create an event handler along the lines of:

Code:
function me.EventHandler(self, event, ...)
    if event == "SOME_EVENT" then
        local msg, sender = ...
        --do other stuff
    elseif event == "SOME_OTHER_EVENT" then
         local msg, channel, language, sender = ...
         --do other stuff
    end
end
3b. The specific parameters for each event are described on the wiki page that I linked above.
  Reply With Quote
06-20-09, 10:31 AM   #3
Nafe
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 17
If you are looking to see if any message is put into a ChatFrame, including messages from other Addons, I believe you would need to hook the ChatFrame :AddMessage() method.

I'm not an expert on hooking, but here's a WoWwiki link to get you started:
http://www.wowwiki.com/Hooking_functions
  Reply With Quote
06-20-09, 12:29 PM   #4
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by Nafe View Post
If you are looking to see if any message is put into a ChatFrame, including messages from other Addons, I believe you would need to hook the ChatFrame :AddMessage() method.]
That is correct; if you want addon messages as well, the best way would be to do something like:

Code:
hooksecurefunc(ChatFrame1, "AddMessage", function(msg) tinsert(someTable, msg) end)
where someTable is the name of the table you want to add the message to.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Get Message


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off