View Single Post
09-20-09, 09:41 AM   #2
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
lua Code:
  1. local function intox(frame, event, msg, ...)
  2.     for i=1,4 do
  3.         if msg:match("DRUNK_MESSAGE_ITEM_OTHER"..i) then
  4.             msg:gsub("%%s", ".*")
  5.         elseif msg:match("DRUNK_MESSAGE_OTHER"..i) then
  6.             msg:gsub("%%s", ".*")
  7.         end
  8.     end
  9. end
  10. ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", intox)

Few problems:

* In a message event filter, you return true to filter the message completely, return false to let it pass unaltered, or return a modified string and the vararg to modify the message.

* The DRUNK_MESSAGE_ITEM_OTHERN and DRUNK_MESSAGE_OTHERN are global variables. You're just comparing your message to a direct string called DRUNK_MESSAGE_ITEM_OTHERN, etc. You want to access the variable.


Code:
local function intox(frame, event, msg, ...)
	for i=1,4 do
		-- access the global variable
		if msg:match(_G["DRUNK_MESSAGE_ITEM_OTHER"..i]) or msg:match(_G["DRUNK_MESSAGE_OTHER"..i]) then
			return true
		end
	end
	return false -- this is probably implied and not needed
end
ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", intox)
Something like that, ish.

Last edited by Waverian : 09-20-09 at 09:44 AM.
  Reply With Quote