Thread Tools Display Modes
09-04-10, 01:07 PM   #1
RightLegRed
A Murloc Raider
Join Date: Sep 2010
Posts: 8
Removing Chat Messages

How would I go about doing this? Like if the messages includes the phrase "[ADN:001]" it would remove the message from the chat frame.


Sorry, I'm new to WoWLua, but I know regular Lua and OOP Lua.


Thanks, Grunné/RightLegRed
  Reply With Quote
09-04-10, 09:29 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You'd want to use the chat message filtering API, and pattern matching:

Code:
local thingsToHide = {
    "%[ADN:001%]",
    "Hide this!",
}

ChatFrame_AddMessageEventFilter("CHAT_MSG_SAY", function(frame, event, message, sender, ...)
    for i, v in ipairs(thingsToHide) do
        if message:find(v) then
            return true -- hide this message
        end
    end
end)
If you just wanted to remove certain words from the message instead of hiding the whole message:
Code:
ChatFrame_AddMessageEventFilter("CHAT_MSG_SAY", function(frame, event, message, sender, ...)
    for i, v in ipairs(thingsToHide) do
        message = message:replace(v, "")
    end
    return false, message, sender, ... -- don't hide this message
    -- note that you must return *all* of the values that were passed to your filter, even ones you didn't change
end)
  Reply With Quote
09-05-10, 04:39 AM   #3
RightLegRed
A Murloc Raider
Join Date: Sep 2010
Posts: 8
Thanks a lot. I'm new to WoWLua and currently I think they ruined the language (with such things as "SetText()" and "GetText"). Helped a lot.


Also, can I use regular Lua? Like 'object.Text = "Hello"'?
  Reply With Quote
09-05-10, 05:15 AM   #4
Nobgul
A Molten Giant
 
Nobgul's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 693
0_o

I think your best bet would be to check out the wowwiki.
  Reply With Quote
09-05-10, 07:33 AM   #5
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by RightLegRed View Post
Thanks a lot. I'm new to WoWLua and currently I think they ruined the language (with such things as "SetText()" and "GetText"). Helped a lot.


Also, can I use regular Lua? Like 'object.Text = "Hello"'?
Methinks you're simply new to Lua. My head just exploded.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
09-26-10, 02:24 AM   #6
RightLegRed
A Murloc Raider
Join Date: Sep 2010
Posts: 8
Originally Posted by Torhal View Post
Methinks you're simply new to Lua. My head just exploded.
"INSTANCE"."PROPERTY" = "VALUE"
is standard of OOP Lua I used.
  Reply With Quote
09-26-10, 04:49 AM   #7
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
When considering the fact that Lua is simply a scripting environment within the WoW Client, it isn't strange that they're using things like "region:GetText()" and "region:SetText()" considering all UI elements are thin table-shaped wrappers around C++ objects.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
09-26-10, 04:59 AM   #8
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
you are allowed though to use

object.text = "someValue"

however, in order to display anything in wow, you need to make use of the widgets. the FontString widget requires you to use :SetText() in order to display properly.

if the widget for the FontString is referenced as "fs" then

fs.text = "my text" --a valid statement, but wont make any visible change

but fs.text is now a real value, moreover text is a key in the table fs

/dump fs would result in

Code:
fs = {
 [0] = FontString Object,
 ["text"] = "my text"
}
the wow client wont let us edit the table index of 0, because this is the C++ wrapper as mentioned above.

so every widget is a table, and you could do fs:SetText(fs.text) if that is a desired change
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Removing Chat Messages


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