Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- How to use the function in an alias. ----------------------------------------------------
- 1. Create a new alias.
- 2. Name it "Says (Stutter Hook)"
- ( or whatever you want)
- 3. Pattern:
- ^(?:\"|\'|say) (.+)$
- 4. Script:
- local str = matches[2]
- send("say " .. StutterText(str), false)
- 5. If you made sure to save the script below, you're ready to rock.
- -- PASTE THE BELOW CODE INTO A NEW SCRIPT IN YOUR SCRIPT EDITOR. ---------------------------
- --[[
- Generic Stutter Function.
- A simple function that accepts text and creates a stuttering effect
- for use in roleplaying.
- by Lin, November 25, 2013
- ]]--
- local stutter = function (word)
- -- This function, available only in this script (s'why it's local),
- -- draws out any word given to it.
- -- Ex: gods --> g- gods
- -- leyline --> l- leyline
- word = tostring(word) -- Make sure the word is a string, just in case
- -- you pass any weirdness to it.
- return word:sub(1, 1) .. "- " .. word
- end
- local plosives = { -- Hard plosive sounds. Not perfect.
- -- See notes below.
- "b", "d", "g", "k", "p", "t", "x",
- "B", "D", "G", "K", "P", "T", "X"
- }
- local stutterWords = { -- Your guaranteed stutter words. These
- -- are words you always want to check for
- -- stuttering.
- "gods", "focus", "boobies"
- }
- local stutterChance = 75 -- Chance (in percentage) of how likely
- -- stuttering will occur.
- local stuttersPerLine = 2 -- Hard limit for how many words to use
- -- for generating stutter.
- local stutterPlosives = true -- true: Will try to stutter words beginning
- -- in plosive sounds (hard d, g, t, etc.).
- -- false: only uses the stutterWords.
- StutterText = function (str)
- if type(str) ~= "string" then
- error("Passed a non-string value to StutterText()!")
- return
- end
- local splCount = 0 -- Number to check against stuttersPerLine.
- str = str:gsub("(%w+)", function (word)
- -- Using gsub, we'll run over every word in the string and check to see if we
- -- should stutter it. Each word is run through this instanced function, with
- -- the word object itself named (appropriately) "word".
- if splCount <= stuttersPerLine then -- Only generate stutter if within the limit.
- if table.contains(stutterWords, string.lower(word)) then -- Check our stutterWords first.
- if math.random(100) <= stutterChance then
- word = stutter(word)
- end
- -- Stuttered a word, so make sure to increment how many stutters we've used.
- splCount = splCount + 1
- elseif stutterPlosives == true then -- If allowed, try to stutter plosive sounds.
- if table.contains(plosives, word:sub(1, 1)) then
- if math.random(100) <= stutterChance then
- word = stutter(word)
- end
- end
- splCount = splCount + 1
- end
- end
- return word
- end)
- return str -- Return the modified text.
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement