stutter script

Post Reply
Darmir
Posts: 226
Joined: Sun May 01, 2011 6:51 pm
Contact:

stutter script

Post by Darmir »

Hello all.
I am a experience mud player, but I have been using CMUD and ZMUD for years and I am finally saying good bye to a client that constantly crashes. I have a package in CMUD that I created called Speech Types which takes what you type in from a channel and converts it to stuttering, old english or lisp.
I am hoping I can get some direction here.
I am going to paste the xml file from cmud hoping I can get some direction from you gurus.
Code: [show] | [select all] lua
<module name="SpeechTypes" global="true">
  <uid>{0D738C53-4D1A-4F3D-854E-E0261D0AD71F}</uid>
  <event event="onLoad" priority="60" id="1">
    <value><![CDATA[#local $curwin
$curwin = %window 
#if ( !@SpeechTypeGV/setup) { 
  #MODULE %window 
  #CLASS SpeechTypeGV 
  #NEWVAR SpeechTypeGV/speech 1 
  #NEWVAR SpeechTypeGV/st_intensity 3 
  #NEWVAR SpeechTypeGV/setup 1 
  #CLASS 0 
  #MODULE 0 
  temp = %session.GetClass("SpeechTypeGV") 
// now set the Comment property 
temp.comment = "This class is used for the Speech Type Package (DO NOT REMOVE)"
#unvar temp
  #PRINT {<color yellow>#################################</color>} 
  #PRINT Speech Types Package has been installed for $curwin 
  SpeechHelp 
  #PRINT {<color yellow>#################################</color>} 
  #PRINT {} 
  }]]></value>
  </event>
  <class name="CommCmnd" keyword="CommCmnd" enabled="false" id="2">
    <notes>This class holds all of the triggers for communications that can use the speech impairments function.</notes>
    <trigger type="Command Input" priority="260" trigontrig="false" id="3">
      <pattern>^say (*)</pattern>
      <value>#local $input
$input = %1
#send @SpeechType(say,$input)
#noinput</value>
      <notes>This trigger is fired with the say command and calls the SpeechType function.</notes>
    </trigger>
    <trigger type="Command Input" priority="290" trigontrig="false" id="4">
      <pattern>^shout (*)</pattern>
      <value>#local $input
$input = %1 
#send @SpeechType(shout,$input)
#noinput</value>
      <notes>This trigger is fired with the shout command and calls the SpeechType function.</notes>
    </trigger>
    <trigger type="Command Input" priority="280" trigontrig="false" id="5">
      <pattern>^talk (*)</pattern>
      <value>#local $input
$input = %1 
#send @SpeechType(talk,$input)
#noinput</value>
      <notes>This trigger is fired with the talk command and calls the SpeechType function.</notes>
    </trigger>
    <trigger type="Command Input" priority="270" trigontrig="false" id="6">
      <pattern>^tell (*)</pattern>
      <value>#local $input
$input = %1 
#send @SpeechType(tell,$input)
#noinput</value>
      <notes>This trigger is fired with the tell command and calls the SpeechType function.</notes>
    </trigger>
    <trigger type="Command Input" priority="320" trigontrig="false" id="7">
      <pattern>^whisper (*)</pattern>
      <value>#local $input
$input = %1 
#send @SpeechType(whisper,$input)
#noinput</value>
      <notes>This trigger is fired with the whisper command and calls the SpeechType function.</notes>
    </trigger>
    <trigger type="Command Input" priority="300" trigontrig="false" id="8">
      <pattern>^yell (*)</pattern>
      <value>#local $input
$input = %1 
#send @SpeechType(yell,$input)
#noinput</value>
      <notes>This trigger is fired with the yel command and calls the SpeechType function.</notes>
    </trigger>
    <trigger type="Command Input" priority="760" trigontrig="false" id="9">
      <pattern>^({@channel}) (*)</pattern>
      <value>#local $input $channel
$channel = %1
$input = %2
#send @SpeechType($channel,$input)
#noinput</value>
      <notes>This trigger is fired with  any command listed in they channel variable  and calls the SpeechType function.</notes>
    </trigger>
  </class>
  <class name="Speech Function" id="10">
    <func name="SpeechType" id="11">
      <value><![CDATA[#local $matched $channel $input $person $sentence $emphasis $loopcount $word $punctuation
$channel = %1
$input = %params( 2)
$loopcount = 0
;Check to see if the channel is a member of the sayto list
#if (%ismember( $channel, @sayto)) {
;Assign person variable and remove person from input variable
  $person = %concat( %word( $input, 1), " ")
  $input = %remove( $person, $input)
  }
;Check for a space a beginning of input and remove
$input = %trim( $input)
;Next check for an emphasis
#if (%begins( $input, "(")) {
  #call %match( $input, "(~(*~))(*)", $emphasis, $sentence)  
;Remove space at beginning of sentence to prepare to change into string list
  $sentence = %trim( $sentence)
  } {$sentence = $input}

;Change sentence into string list
$sentence = %replace( $sentence, " ", "|")
;Check which speech to do.
#forall $sentence {
      #add $loopcount 1
  #switch     (@SpeechTypeGV/speech=2) {
    // Turn the sentence into stutter speech
    #if (%match( %i, %concat( "^({", @stutterlist, "})*"), $matched)) {#if (%random( 1, @SpeechTypeGV/st_intensity)=1) {
        //Need to change intensity of the stutter when it is a question or exclamation point at the end of the sentence
        $word = %concat( $matched, "-", $matched, "-", %i)        
        $sentence = %replaceitem( $word, $loopcount, $sentence)
        }}
    } (@SpeechTypeGV/speech=3) {
;Need to check for punctuation for Old English since checking again the full word not just part of it.
$punctuation = %null
#if (%match(%i,~(%p~),$punctuation)) {
  $word = %remove( $punctuation, %i)
 } { $word = %i }
    #if (%match( $word, %concat( "^({", %dbkeys(@OldEnglish), "})$"), $matched )) {
    $sentence = %replaceitem(@OldEnglish.$word$punctuation,$loopcount,$sentence)
}} (@SpeechTypeGV/speech=4) {
    // Turn the sentence into a lisp speech
    #if (%match( %i, %concat( "({", @lisplist, "})"), $matched)) {
      $word = %replace( %i, $matched, "th")
      $sentence = %replaceitem( $word, $loopcount, $sentence)
      }
    } 
  }
;Replace pipe symbols with space to display remaining input
$sentence = %expandlist( $sentence, " ") 
;********* Display the finished output ***********************
#if (($channel =~ "shout" || $channel =~ "yell") && ($emphasis)) {
  #print <color red>You can't use emphasis with shout</color>
  #return {$channel $sentence}
  } 
{#return {$channel $person %quote( $emphasis) $sentence}}]]></value>
    </func>
  </class>
  <class name="Global Variables" id="12">
    <var name="channel" type="StringList" id="13">
      <value>esay|gossip|say|shout|sing|talk|tell|whisper|yell|etalk</value>
      <json>["esay","gossip","say","shout","sing","talk","tell","whisper","yell","etalk"]</json>
      <notes>This variable holds all communication commands for RP purposes. DON'T PUT IN COMMUNCAITON COMMANDS THAT YOU DON'T WANT PARSED.</notes>
    </var>
    <var name="sayto" type="StringList" id="14">
      <value>tell|whisper</value>
      <json>["tell","whisper"]</json>
      <notes>This variable is for channels the have a target.
> tell [target] [message]</notes>
    </var>
  </class>
  <class name="Stuttering" id="15">
    <notes>1) Stutter more on certain behaviors.
2) Use Hot Keys to make stuttering more.
3) Fix when you use punctuation like ! and ? for SOI. Those change the output.</notes>
    <alias name="stu" parsearg="false" id="16">
      <value>#local $channel, $input
$channel = %1 
$input = %params( 2) 
#variable SpeechTypeGV/speech 2
#class CommCmnd 0
#send @SpeechType($channel,$input)</value>
      <notes>Alias used to create stutter speech type</notes>
    </alias>
    <alias name="StutterTimeIntensity" id="17">
      <value>#VARIABLE SpeechTypeGV/st_intensity %1</value>
      <notes>This alias is used to delay the time of the stutter. The higher the number the less the character will stutter.</notes>
    </alias>
    <var name="stutterlist" type="StringList" id="18">
      <value>th|ch|st|tr|bl|br|bl|sp|sc|t|h|g|i|c|l|j|y|d|an|w|f|a|s</value>
      <json>["th","ch","st","tr","bl","br","bl","sp","sc","t","h","g","i","c","l","j","y","d","an","w","f","a","s"]</json>
      <notes>This is the list of letters that the character will stutter on.</notes>
    </var>
  </class>
  <class name="Old English" id="19">
    <alias name="ole" id="20">
      <value>#local $channel, $input
$channel = %1 
$input = %params( 2) 
#variable SpeechTypeGV/speech 3
#class CommCmnd 0
#send @SpeechType($channel,$input)</value>
      <notes>Alias used to create Old English speech</notes>
    </alias>
    <var name="OldEnglish" type="Record" id="21">
      <value>asked=besought|above=onuppan|a lot=overmany|you=thou|has=hath|had=hath|ask=beseech|are=art|from where=whence|to know=wit|to grow=wax|to give=bequeath|plentiful=fullsome|apprentice=proby|nothing=naught|to linger=tarry|yours=thine|horrible=pudh|do=dost|to where=whither|years ago=yore|friend=fere|from now on=henceforth|there=thither|your=thy|will=shalt|sell=syllan|rich=fullsome|pull=draught|none=nary|lake=mere|knew=wist|here=hither|have=hath|fork=pece|does=dost|dare=durst|I pray thee=prithee|to think=trow|coming=cometh|comes=cometh|you're=thou art|to become=wax|companion=fere|between=betwixt|request=beseech</value>
      <json>{"asked":"besought","above":"onuppan","a lot":"overmany","you":"thou","has":"hath","had":"hath","ask":"beseech","are":"art","from where":"whence","to know":"wit","to grow":"wax","to give":"bequeath","plentiful":"fullsome","apprentice":"proby","nothing":"naught","to linger":"tarry","yours":"thine","horrible":"pudh","do":"dost","to where":"whither","years ago":"yore","friend":"fere","from now on":"henceforth","there":"thither","your":"thy","will":"shalt","sell":"syllan","rich":"fullsome","pull":"draught","none":"nary","lake":"mere","knew":"wist","here":"hither","have":"hath","fork":"pece","does":"dost","dare":"durst","I pray thee":"prithee","to think":"trow","coming":"cometh","comes":"cometh","you're":"thou art","to become":"wax","companion":"fere","between":"betwixt","request":"beseech"}</json>
      <notes>The keys are the words to be changed from in the value field.
Script still needs to figure out keys with more than  one word.</notes>
    </var>
  </class>
  <class name="Lisp" id="22">
    <alias name="lisp" id="23">
      <value>#local $channel, $input
$channel = %1 
$input = %params( 2) 
#variable SpeechTypeGV/speech 4
#class CommCmnd 0
#send @SpeechType($channel,$input)</value>
      <notes>Alias used to create a lisp speech</notes>
    </alias>
    <var name="lisplist" type="StringList" id="24">
      <value>s|z|sh|ch|j</value>
      <json>["s","z","sh","ch","j"]</json>
      <notes>The values in this string list variable are converted to the "th" sound to create a lisp speech.</notes>
    </var>
  </class>
  <class name="Help Files" id="25">
    <notes>General Help files</notes>
    <alias name="LispHelp" id="26">
      <value><![CDATA[#CLR
#PRINT {}
#PRINT {<color DarkCyan>Alias: lisp</color>}
#PRINT {<color white>This alias is used to make your character have a lisp. See more information below.</color>}
#PRINT {}
#PRINT {<color white>Usage: lisp <channel> <person></color>}
#PRINT {}
#PRINT {<color white>The lisp alias allows your character to speak to other</color>} 
#PRINT {<color white>characters with a lisp. This alias also supports</color>}
#PRINT {<color white>changing of one's voice string on the fly</color>}
#PRINT {<color green>(for muds that support voice strings)</color><color white>.In order to do this,</color>}
#PRINT {<color white>specify your new temporary voice string in parenthases at</color>}
#PRINT {<color white>the beginning of your statement;</color> }
#PRINT {<color white>you may use both * and (tilde) tokens to reference objects and mobiles, respectively.</color> }
#PRINT {}
#PRINT {<color white>> lisp say (lifts *tankard, nodding to [tilde]kieran) Thanks!</color>}
#PRINT {<color white>outputs: lisp (lifts *tankard, nodding to [tilde]kieran) Thankth!</color>}
#PRINT {}
#PRINT {<color white>> stu tell kieran (lifting a brow) You want how much?</color>}
#PRINT {<color white>outputs: tell kieran (lifting a brow) You want how muth?</color>}
#PRINT {}
#MXP {<color DarkCyan>Related Topic:</color> <send 'SpeechHelp'><color cyan>SpeechHelp</color></send>}]]></value>
      <notes>Lisp Speech helpfile</notes>
    </alias>
    <alias name="OleHelp" id="27">
      <value><![CDATA[#CLR
#PRINT {}
#PRINT {<color DarkCyan>Alias: ole</color>}
#PRINT {<color white>This alias is used to make your character speak in Old English. See more information below.</color>}
#PRINT {}
#PRINT {<color white>Usage: ole <channel> <person></color>}
#PRINT {}
#PRINT {<color white>The Old Enlish alias allows your character to speak to other</color>} 
#PRINT {<color white>characters in Old English style speech. This alias also</color>}
#PRINT {<color white>supports changing of one's voice string on the fly</color>}
#PRINT {<color green>(for muds that support voice strings)</color><color white>.In order to do this,</color>}
#PRINT {<color white>specify your new temporary voice string in parenthases at</color>}
#PRINT {<color white>the beginning of your statement;</color>}
#PRINT {<color white>you may use both * and (tilde) tokens to reference objects and mobiles, respectively.</color>}
#PRINT {}
#PRINT {<color white>> ole say (lifts *tankard, nodding to [tilde]kieran) Thank you my companion.</color>}
#PRINT {<color white>outputs: say (lifts *tankard, nodding to [tilde]kieran) Thank thou my fere.</color>}
#PRINT {}
#PRINT {<color white>> ole tell kieran (lifting a brow) Are you coming?</color>}
#PRINT {<color white>outputs: tell kieran (lifting a brow) Art thou cometh?</color>}
#PRINT {}
#MXP {<color DarkCyan>Related Topic:</color> <send 'SpeechHelp'><color cyan>SpeechHelp</color></send>}]]></value>
      <notes>Old English Speech helpfile</notes>
    </alias>
    <alias name="SpeechHelp" id="28">
      <value><![CDATA[#PRINT {}
#PRINT {<color red><b>This Package was created for Roleplay purposes for speech types.</b></color>}
#PRINT {<color cyan>You can choose different speech types by selecting from the speech button.</color>}
#PRINT {<color cyan>Once selected just type as you would for your mud and it should produce</color>}
#PRINT {<color cyan>the speech type you want.</color>}
#PRINT {}
#MXP {<color white>See</color> <send 'StuHelp'><color cyan>StuHelp</color></send><color white> for stutter alias help}
#PRINT {}
#MXP {<color white>See</color> <send 'OleHelp'><color cyan>OleHelp</color></send> <color white>for Old English alias help</color>}
#PRINT {}
#MXP {<color white>See</color> <send 'LispHelp'><color cyan>LispHelp</color></send> <color white>for lisp alias help</color>}]]></value>
      <notes>General helpfile</notes>
    </alias>
    <alias name="StuHelp" id="29">
      <value><![CDATA[#CLR
#PRINT {}
#PRINT {<color DarkCyan>Alias: stu</color>}
#PRINT {<color white>This alias is used to make your character stutter. See more information below.</color>}
#PRINT {}
#PRINT {<color white>Usage: stu <channel> <person></color>}
#PRINT {}
#PRINT {<color white>The stutter alias allows your character to speak to other</color>} 
#PRINT {<color white>characters with a stutter. This alias also supports</color>}
#PRINT {<color white>changing of one's voice string on the fly</color>}
#PRINT {<color green>(for muds that support voice strings)</color><color white>.In order to do this,</color>}
#PRINT {<color white>specify your new temporary voice string in parenthases at</color>}
#PRINT {<color white>the beginning of your statement;</color> }
#PRINT {<color white>you may use both * and (tilde) tokens to reference objects and mobiles, respectively.</color> }
#PRINT {}
#PRINT {<color white>> stu say (lifts *tankard, nodding to [tilde]kieran) Thanks!</color>}
#PRINT {<color white>outputs: say (lifts *tankard, nodding to [tilde]kieran) Th-Th-Thanks!</color>}
#PRINT {}
#PRINT {<color white>> stu tell kieran (lifting a brow) You want how much?</color>}
#PRINT {<color white>outputs: tell kieran (lifting a brow) Y-Y-You want how m-m-m-much?</color>}
#PRINT {}
#PRINT {<color DarkCyan>Related Alias: StutterTimeIntensity</color>}
#PRINT {<color white>This alias is used to delay the time of your stutter. The higher the number the less your character will stutter.</color>}
#PRINT {<color white>Usage: StuterTimeIntensity 3</color>}
#PRINT {Currently set to: @}
#PRINT {}
#MXP {<color DarkCyan>Related Topic:</color> <send 'SpeechHelp'><color cyan>SpeechHelp</color></send>}]]></value>
      <notes>Stutter speech helpfile</notes>
    </alias>
    <alias name="VHistory" id="30">
      <value><![CDATA[#PRINT {<color yellow>-------- Version History ----------</color>}
#PRINT {<color cyan>v3.2.7</color>}
#PRINT {<color white>- Fixed issues with v3.2.6. Added changes back in</color>}
#PRINT {<color white>- Added Version History Help file</color>}
#PRINT {<color cyan>v3.2.6</color>}
#PRINT {<color white>- Backed out changes from vesion3.2.5</color>}
#PRINT {<color cyan>v3.2.5</color>}
#PRINT {<color white>- Modified package to be able to save setting in the mud session versus in the package. This mean you can have the package loaded to multiple mud session and they don't get confused!</color>}
#PRINT {<color white>- Added version history helpfile.</color>}
#PRINT {<color cyan>v3.2.4</color>}
#PRINT {<color white>- Fixed package from previous upload. All classes were messed up.</color>}
#PRINT {<color cyan>v3.2.3</color>}
#PRINT {<color white>- Fixed an issue with stu alias not setting speech variable</color>}
#PRINT {<color white>- Combined command triggers into one trigger with a new variable called channel</color>}
#PRINT {<color white>- Added notes to variables, functions, triggers and button</color>}
#PRINT {<color cyan>v3.2.2</color>}
#PRINT {<color white>- Fixed matching issue with Old English speech type to be more specific</color>}
#PRINT {<color cyan>v3.2.1</color>}
#PRINT {<color white>- Fixed SpeechType function to parse correctly</color>}
#PRINT {<color white>- Updated help files</color>}
#PRINT {<color cyan>v3.2</color>}
#PRINT {<color white>- Created Speech Type function which replaced the alias, this makes it easier to add more speech types</color>}
#PRINT {<color white>- Added Old English Speech Type</color>}
#PRINT {<color white>- Updated help files</color>}
#PRINT {<color white>- Added Lisp Speech Type</color>}
#PRINT {<color white>- Added triggers to parse words from command line instead of using the speech type alias</color>}
#PRINT {<color white>- Created a button which you can change the speech type from.</color>}
#PRINT {<color cyan>v3.1</color>}
#PRINT {<color white>- Rewrite of package to use the latest functionality of v3 of CMUD.</color>}
#PRINT {<color cyan>v2.0</color>}
#PRINT {<color white>- Total rewrite of stutter script from zMUD.</color>}]]></value>
    </alias>
  </class>
  <button type="Multistate" variable="@SpeechTypeGV/speech" autosize="false" width="86" height="24" autopos="false" left="-2" top="-2" toolbar="2" border="red" priority="630" id="63">
    <caption>Command</caption>
    <button border="red" id="64">
      <caption>Command</caption>
      <value>#class CommCmnd 0</value>
    </button>
    <button id="65">
      <caption>Stutter</caption>
      <value>#class CommCmnd 1</value>
    </button>
    <button id="66">
      <caption>Old English</caption>
      <value>#class CommCmnd 1</value>
    </button>
    <button id="67">
      <caption>Lisp</caption>
      <value>#class CommCmnd 1</value>
    </button>
  </button>
</module>
To start how do you capture lets say what you say.
say This is a test.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: New user to mudlet. Need help understanding

Post by Heiko »

stutter example on says and tells import via import button in the trigger editor
Attachments
stutterAlias.xml.xml
(1.86 KiB) Downloaded 628 times

Post Reply