Page 2 of 2

Re: stutter script

Posted: Sat Sep 10, 2011 6:24 am
by tsuujin
You've got the right idea at the start of the script. Tokenize the string with string.split, but then use that table instead of trying to modify the original message.

Here's a hacked out example:
Code: [show] | [select all] lua
function stutter(stChan, stTar, stMsg)
	local stChannels = {"say","shout","tell","whisper","yell"}

	local stStutters = {"th","ch","st","tr","bl","br","bl","sp","sc","t","h",
                    "g","i","c","l","j","y","d","n","w","f","a","s"}

	if not table.contains(stChannels,stChan) then return false end
	if stChan == "tell" then stMsg = string.format("%s %s",stTar,stMsg) end
	
	local tokens = string.split(stMsg, " ")

	for index,word in pairs(tokens) do
		for _,st in pairs(stStutters) do
			if string.starts(word,st) then
				tokens[index] = string.format("%s-%s-%s",st,st,word)
				break
			end
		end
	end
	display(table.concat(tokens, " "))
end
This way you're just working one word a time, like you should be.

You can test the function with:
Code: [show] | [select all] lua
stutter("say","dude","this is a test")
-- output: 'th-th-this i-i-is a-a-a t-t-test'
edit: I feel compelled to point out that I have always hated when people use speech impediments as a character mechanic. Yes, it offers a sense of realistic non-perfection... but it also offers a sense of hyper-realistic irritation to many players. I've found myself griefing several of them in the past and I'm honestly not a griefer.

Re: stutter script

Posted: Sat Sep 10, 2011 1:04 pm
by Darmir
Thanks for the help. I understand your grief with speech impediments like this, but I like it because I hate having to type it all the extra stuff and this is quicker.

Re: stutter script

Posted: Sat Sep 10, 2011 2:13 pm
by Rakon
Darmir wrote:Thanks for the help. I understand your grief with speech impediments like this, but I like it because I hate having to type it all the extra stuff and this is quicker.
I don't think you quite addressed Tsuujin's complaint.

He's not upset that you're using a script to do the stuttering. He is saying, that character mechanics such as 'speech impediments' (like stuttering) are an irritation to players, not a character developing of intrigue.

I agree with Tsuujin.

Re: stutter script

Posted: Sun Sep 11, 2011 12:29 am
by Darmir
Rakon wrote:
Darmir wrote:Thanks for the help. I understand your grief with speech impediments like this, but I like it because I hate having to type it all the extra stuff and this is quicker.
I don't think you quite addressed Tsuujin's complaint.

He's not upset that you're using a script to do the stuttering. He is saying, that character mechanics such as 'speech impediments' (like stuttering) are an irritation to players, not a character developing of intrigue.

I agree with Tsuujin.
LOL. Okay. I like them because they give the character more character. Some players have their characters walk with a limp, some are very beligerant.. This character has a speech impediment. ;)

Re: stutter script

Posted: Mon Sep 12, 2011 3:28 pm
by tsuujin
I'm just pointing out the fact that by using this script, you're very likely going to piss off a few players. Don't be surprised when you take verbal grief over using this script, and don't complain when other people go out of their way to grief your character.

If I were you I'd simply reduce the number of times you actually stutter dramatically. For example, cutting your stutterlist by three quarters.

Re: stutter script

Posted: Mon Sep 12, 2011 4:22 pm
by Darmir
tsuujin wrote:I'm just pointing out the fact that by using this script, you're very likely going to piss off a few players. Don't be surprised when you take verbal grief over using this script, and don't complain when other people go out of their way to grief your character.

If I were you I'd simply reduce the number of times you actually stutter dramatically. For example, cutting your stutterlist by three quarters.
I don't have it stutter on every word. I does a math.random on the words. The stutter Intensity can be changed with an alias. :D

Re: stutter script

Posted: Mon Dec 12, 2011 8:21 pm
by Darmir
Please remove

Re: stutter script

Posted: Thu Jan 05, 2012 3:03 pm
by DevArrah
what you want to do at a high level is split the string or do something like
Code: [show] | [select all] lua
(\s?(\S+))+?
then iterate over each word to see if starts with one of the stuttering patterns. Once the iteration is done, reassemble the string and send it.