Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-16-10, 07:28 AM   #1
Dzib
A Deviate Faerie Dragon
Join Date: Nov 2010
Posts: 16
Transforming an existing addon

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
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Transforming an existing addon


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off