View Single Post
11-17-10, 01:00 AM   #9
Dzib
A Deviate Faerie Dragon
Join Date: Nov 2010
Posts: 16
Originally Posted by Phanx View Post
If all you want to do is double the letter "r", then your code is way more complicated than it needs to be. Try this:

Code:
local old = SendChatMessage

local new = function(message, ...)
	if message:len() > 0 and not message:match("^/") then
		message = message:replace("r", "rr"):replace("rrrr", "rr"):replace("R" "RR"):replace("RRRR", "RR")
	end
	old(message, ...)
end

SendChatMessage = new

SLASH_ADDONNAME1 = "/doubler"

SlashCmdList.ADDONNAME = function()
	if SendChatMessage == new then
		SendChatMessage = old
		DEFAULT_CHAT_FRAME:AddMessage("AddonName disabled.")
	else
		SendChatMessage = new
		DEFAULT_CHAT_FRAME:AddMessage("AddonName enabled.")
	end
end
It'll work for both lowercase and capital letters, and won't double any "r" that's already doubled (eg. if you type "arrange" it won't end up as "arrrrange").
You mean this replace the whole code I posted above? Much more simple, I agree
Thanks for the responses.... what about applying the modification only if I'm talking in the guild/say/yell channel? Is it possible?
  Reply With Quote