Originally Posted by Phanx
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?