Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Mon Sep 13, 2010 8:46 pm   

Stutter Script concerns
 
I have an issue with part of my stutter script.
Up to the following code it works good. And even this does to a point.

I have the following variables:
#VAR stutterlist {th|m|i|b|t|g}
#VAR sentence {I|want| to|run|to|the|street|and|back.}

When the code runs it stutters but I want it to capture "th" instead of the "t" to stutter on. It will change to the "th" then it changes to the "t", but this is random. I was thinking of moving the consonent clusters to another variabe say: #VAR const_clust {th|br|gr|st|bl}, but I am not sure how to get it to check those first and ignore the other list.
Here is my code for the stuttering part of the script:
Code:

#FORALL @sentence {
  #ADD loopcount 1
  #FORALL @stutterlist {
    #IF %begins( %i, %j) {
      #print value of i: %i
      #print value of j: %j
      #IF (%random( 1, 3)=1) {
        //#IF (%i = "I" ) {#SHOW Should make this proper case.}
        #VARIABLE s_word %concat( %j, "-", %j, "-", %i)
        #print "s_word:" @s_word
        #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
      }
    }
    //This IF is to check for Proper words.
    #IF %begins( %i, %proper( %j)) {
      #print "%i in second if:" %i
      #print "%j in second if:" %j
     
      #IF (%random( 1, 3)=1) {
        //#IF (%i = "I" ) {#SHOW Should make this proper case.}
        #VARIABLE s_word %concat( %proper( %j), "-", %proper( %j), "-", %i)
        #VARIABLE input %replaceitem( @s_word, @loopcount, @sentence)
      }
    }
  }
}
;Replace pipe symbols with space to display remaining input
#VARIABLE sentence %replace( @sentence, "|", " ")
 
;********* Display the finished output ***********************
#IF (@channel =~ "shout" || @channel =~ "yell")
{#print You can't use emphasis with shout.
 @channel @sentence}
 {@channel @person %quote( @emph) @sentence}
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)

Last edited by darmir on Tue Sep 14, 2010 3:17 pm; edited 1 time in total
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Sep 14, 2010 1:02 pm   
 
One way to do it is to replace
Code:
#FORALL @stutterlist {

with:
Code:
#IF (%match(%i,%concat("^{(",@stutterlist,")}.*),$matched)) {

Then use $matched instead of %j. You may also need to add "#LOCAL $matched" to the beginning of your code. The advantage of this is that it only has to check once to see whether the word begins with one of the stutterlist values; it doesn't loop through the entire list, testing every one of them. This should solve your problem.

As an aside, do you want "tr" to stutter into "t-tr"? I would put "tr" into @stutterlist, myself. Nice code! I've considered making some 'jive'-like code myself.

One other suggestion I would make is to change the line
Code:
#VARIABLE sentence %replace( @sentence, "|", " ")

with:
Code:
#variable sentence %expandlist(@sentence," ")

The previous line will work, but the second line will work even if the internal storage format of stringlists changes. It is best not to depend on the specifics of the internal format if you don't have to, and %expandlist() is designed for exactly this purpose.
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Tue Sep 14, 2010 2:38 pm   
 
I changed the line to the following but I am getting unmatched parenthesis. I fixed it by changing from:

Code:
#IF (%match(%i,%concat("^{(",@stutterlist,")}.*),$matched)) {

To
Code:
#IF (%match(%i,%concat("^{(",@stutterlist,")}.*"),$matched)) {


When I did all of your recommended changes it doesn't stutter at all. It isn't even getting into the if statement.
Below is all of the code for the stutter alias

Code:

#VARIABLE channel %1
#VARIABLE input %params( 2)
#VARIABLE person ""
#variable sentence ""
#VARIABLE emph ""
#VARIABLE loopcount 0
#VARIABLE s_word ""
#LOCAL $matched

;Check to see if the channel is a member of the sayto list
#IF (%ismember( @channel, @sayto)) {
  #VARIABLE person %concat( %word( @input, 1), " ")
  #variable input %remove( @person, @input)
  }

;Next check for an emphasis
#IF (%begins( @input, "(") || %begins( @input, " " )) {
  #CALL %match( @input, "(~(*~))(*)", emph, sentence)
  #variable sentence %remove( " ", @sentence)
  #VARIABLE sentence %replace( @sentence, " ", "|")
  } {
  #variable sentence @input
   #VARIABLE sentence %replace( @sentence, " ", "|")
  }

;Now check the remaining input variable and make it stutter
 #FORALL @sentence {
  #ADD loopcount 1
  #IF (%match(%i,%concat("^{(",@stutterlist,")}.*"),$matched)) {
    #IF %begins( %i, $matched) {
      #IF (%random( 1, 3)=1) {
        #IF (%i = "I" ) {#SHOW Should make this proper case.}
          #VARIABLE s_word %concat( $matched, "-", $matched, "-", %i)
          #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
        } //END RANDOM IF
      } // END BEGINS IF
//This IF is to check for Proper words.
    #IF %begins( %i, %proper($matched)) {
      #IF (%random( 1, 3)=1) {
        #IF (%i = "I" ) {#SHOW Should make this proper case.}
        #VARIABLE s_word %concat( %proper($matched), "-", %proper($matched), "-", %i)
        #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
        }
      }
    }
  }
;Replace pipe symbols with space to display remaining input
;#VARIABLE sentence %replace( @sentence, "|", " ")
#variable sentence %expandlist(@sentence," ")
;********* Display the finished output ***********************
#IF (@channel =~ "shout" || @channel =~ "yell")
{#print You can't use emphasis with shout.
 @channel @sentence}
 {@channel @person %quote( @emph) @sentence}
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Sep 14, 2010 5:26 pm   
 
Oops, I mixed up the syntax for the %match, and put in some regex code. Try this code, for the stutter section:
Code:

;Now check the remaining input variable and make it stutter
 #FORALL @sentence {
  #ADD loopcount 1
  #IF (%match(%i,%concat("^(",@stutterlist,")*"),$matched)) {
    #IF (%random( 1, 3)=1) {
      #IF (%i = "I" ) {#SHOW Should make this proper case.}
      #VARIABLE s_word %concat( $matched, "-", $matched, "-", %i)
      #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
      } //END RANDOM IF
//This IF is to check for Proper words.
    #IF %begins( %i, %proper($matched)) {
      #IF (%random( 1, 3)=1) {
        #IF (%i = "I" ) {#SHOW Should make this proper case.}
        #VARIABLE s_word %concat( %proper($matched), "-", %proper($matched), "-", %i)
        #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
        }
      }
    }
  }
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Tue Sep 14, 2010 5:45 pm   
 
Well I tried that and still no stutter.
Here is the what I say:
stutter say "(while smiling)" This is a test of the stutter script.

and the output is:

You say, while smiling,
"This is a test of the stutter script."

If you want to test it create an account on Shadows of Isildur mud and go into the guest area. You can test it there.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Sep 15, 2010 12:28 pm   
 
Hm. I seem to be messing up the %match() line. I'm afraid I don't have Cmud installed on this machine, so I can't check it here. But try this line:
Code:
#IF (%match(%i,"^(@stutterlist)*",$matched)) {
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Wed Sep 15, 2010 2:37 pm   
 
I already tried the following line. I am not sure how to get it to match a string list variable.
Code:

#IF (%match(%i,"^(@stutterlist)*",$matched)) {
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Sep 15, 2010 10:14 pm   
 
it's the same way as in a trigger pattern.

"...{item|item|item}..."
_________________
EDIT: I didn't like my old signature
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Thu Sep 16, 2010 1:46 am   
 
Zugg answered this for me in the Beta forum...
But now for some reason I thought the match function would do my consonant constructors for me. I now need help on how to get those recognized and not get over written with another letter. For instance I have "th" and "t" in my lists. Now I want the "th" to stutter on word lie the and not have the "t" stutter on that kind of word. Any ideas?
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Sep 16, 2010 12:59 pm   
 
Hm. I thought that the %match would put the first matched string into the $matched field, so that it would simply depend on the order of the strings within @stutterlist. Have you tried reordering the strings in @stutterlist? If that doesn't work, I guess I'll have to think about it some more.
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Thu Sep 16, 2010 4:03 pm   
 
Here is the order of the list:
th|ch|st|tr|bl|br|bl|sp|t|h|g|i|c|l|j

Weird. I tried it today and I can't get it to fail. Maybe I was using the scirpt to test when that happened.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
orphean
Apprentice


Joined: 21 Oct 2008
Posts: 147
Location: Olympia, WA

PostPosted: Thu Sep 16, 2010 4:53 pm   
 
I don't have any input towards the problem but I just wanted to say what a neat idea for a script. When it gets up and running I'd love to see a sample session of the script in use.
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Thu Sep 16, 2010 4:57 pm   
 
I do have this part finished. It is going to be a complete communication script. This includes windows for tells, say, etc.. but with those I need to see if I can create an alias you run and prompted for certain things then which creates the tells for your mud.
To do this. I really need different communication responses from a bunch of muds. If anybody wants to contribute to that I would appreciate it.

Also if anybody has suggestions of what else to put into this script be cool. I am going to update the script in the package Library with the stutter communication sometime today.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
orphean
Apprentice


Joined: 21 Oct 2008
Posts: 147
Location: Olympia, WA

PostPosted: Thu Sep 16, 2010 5:01 pm   
 
Fantastic, I'll have to check it out tonight when I get home from work.

Regarding the 'installer' alias for the communications package my only suggestion would be to make it the more general the better. Maybe include patterns for some set of large muds and if its another mud make the user provide the necessary patterns for the communication responses? Just an idea.
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Thu Sep 16, 2010 5:03 pm   
 
That is my idea. I play Shadow of Isildur mud. Their communication is quite different than other muds, so I will need some examples.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net