Hi
I'd like to make an addon which add the letters "rr" after each "r" detected in the chat (like someone who's rolling r's)
Being a total newbie in programming, I took an addon which adds an "o" after every consonant and tried to modify it.
Here's the original code:
Code:
function doRoevar(str)
local endstr = "";
local konsonanter = {"b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","z"};
local bokstvr = {};
for i = 1,string.len(str) do
bokstvr[i] = string.sub(str,i,i);
for t = 1,19 do
if (string.lower(bokstvr[i]) == konsonanter[t]) then
bokstvr[i] = bokstvr[i] .. "o" .. string.lower(bokstvr[i]);
end
end
endstr = endstr .. bokstvr[i];
end
return endstr;
end
And here's the code I've modified
Code:
function doRoevar(str)
local endstr = "";
local konsonanter = {"r"};
local bokstvr = {};
for i = 1,string.len(str) do
bokstvr[i] = string.sub(str,i,i);
for t = 1,19 do
if (string.lower(bokstvr[i]) == konsonanter[t]) then
bokstvr[i] = bokstvr[i] .. "r" .. string.lower(bokstvr[i]);
end
end
endstr = endstr .. bokstvr[i];
end
return endstr;
end
I'm sur I could simplfy the function but I'm a bit afraid of blowing up eveything. Anyway, it works this way but the only thing I can't find out is how to activate the function only if I'm talking in the guild/say/yell chat???
Thanks