View Single Post
09-20-09, 09:54 AM   #3
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
In addition:
The gsub(), as you already said, is necessary to match the pattern correctly, because "%s" would only match one character, but we need to match multiple ones.

Code:
local function intox(frame, event, msg, ...)
	for i=1,4 do
		-- access the global variable
		local drunk1 = _G["DRUNK_MESSAGE_ITEM_OTHER"..i]:gsub("%%s", "%s-")
		local drunk2 = _G["DRUNK_MESSAGE_OTHER"..i]:gsub("%%s", "%s-")
		if msg:match(drunk1) or msg:match(drunk2) then
			return true
		end
	end
	return false -- this is probably implied and not needed
end
ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", intox)
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote