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: Thu Oct 21, 2010 7:34 pm   

A button alias for command line.
 
I am looking for some ideas here. I have my Scripting Impairments Package which only does stuttering. Now I want to also make it a hissing scripts and and old English script.
Now my thought was if I could create a button that has a toggle for the type of speech impairments and somehow to from the command line it knows which alias to run and put in front of the text.

This may not be possible, so for you gurus what do you think and how would you do it. I want to make it modular enough and show of the CMUD capabilities. Wink
_________________
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
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Thu Oct 21, 2010 9:31 pm   
 
Your speech scripts will be changing what is sent to the mud depending on what you type right, like if you type: say I'm stuttering now. The script will convert "I'm stuttering now" into a something else and send it?

If I understand you right you want to end up with a button that will chose one of the X number of speech packages to use? It seems to me like you could set up the module to have the button, then a class for each of the speech packages. You could make the button be multistate, where when one of the packages is selected from the drop down menu, that class is enabled and all others are disabled. So as long as each script knows if you type "say whatever" you want to use the type of speech that package will cause this method should work. I could just not be understanding the question right though.
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Thu Oct 21, 2010 11:02 pm   
 
Fizgar,
That is exactly what i was thinking, but my question is can you send the alias from the command line without typing it. So let's say I have the stutter class enabled with the button.
I type in the command line the following: say This is the stutter script.
And what is sent to the mud is: stutter say This is the stutter scirpt.
The alias runs and you get: say Th-th-this is the st-st-stutter s-s-script.
_________________
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: Thu Oct 21, 2010 11:28 pm   
 
Feel like reworking your aliases into functions? I would do that, perhaps retaining the use of aliases for when the user wants to send something from the commandline manually (the aliases would now call the function, however).

Once the functions are working like they should, I'd also create a command-line trigger for your generic speech commands. This would cover the "natural" use of MUD speech, giving you a chance to determine if one/any of the speech functions needs to be used.

A menu button (a multistate is probably similar enough in function that the choice is purely a preferential one) would then serve to let the user pick and choose. Each option caption could incorporate variables to show the on/off state, or if you have lots of screenspace you could make a long main-button caption to show which options are active.

Personally, however, I would probably use a clickable MXP link menu in a user-created window that includes space for a nice always-viewable list. Lots of buttons tends to make for slower scripting due to all the screen-refreshing. Might not be a concern with just one script with a handful of buttons, but with dozens of scripts it gets real laggy for me.
_________________
EDIT: I didn't like my old signature
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Oct 22, 2010 1:32 am   
 
MattLofton wrote:
Feel like reworking your aliases into functions? I would do that, perhaps retaining the use of aliases for when the user wants to send something from the commandline manually (the aliases would now call the function, however).

Once the functions are working like they should, I'd also create a command-line trigger for your generic speech commands. This would cover the "natural" use of MUD speech, giving you a chance to determine if one/any of the speech functions needs to be used.

A menu button (a multistate is probably similar enough in function that the choice is purely a preferential one) would then serve to let the user pick and choose. Each option caption could incorporate variables to show the on/off state, or if you have lots of screenspace you could make a long main-button caption to show which options are active.

Personally, however, I would probably use a clickable MXP link menu in a user-created window that includes space for a nice always-viewable list. Lots of buttons tends to make for slower scripting due to all the screen-refreshing. Might not be a concern with just one script with a handful of buttons, but with dozens of scripts it gets real laggy for me.

Matt,
I didn't think about functions. If I send you my script do you think you can look at it and give me some ideas on how to do it? Or you can just download it from the script library.
_________________
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: Fri Oct 22, 2010 2:39 am   
 
Err, what's the "it" part? To convert your STU alias to a function, you just create a new Function and paste your alias code there (where you use #SEND, change it to #RETURN or optionally put a #RETURN "" at the end). Any further changes are independent of the conversion from alias to function and would perhaps work equally well if you stayed with the alias. Should you move to a function, however, if you decide to keep the STU alias the new code would then be:

#SEND @stutter(required parameters) <-- use this if you changed #SEND to #RETURN

#CALL @stutter(required parameters) <-- use this if you did #RETURN "" instead
_________________
EDIT: I didn't like my old signature
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Oct 22, 2010 4:14 am   
 
Matt, I am trying change the script over to a function and it works kind of. Here is the function:
Code:


<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <func name="SpeechType">
    <value><![CDATA[#local $matched $channel $input $person $sentence $emphasis $loopcount $s_word
$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, " ", "|")
;Now check the remaining input variable and make it stutter
 #forall $sentence {
  #add $loopcount 1
  #if (%match( %i, %concat( "^({", @stutterlist, "})*"), $matched)) {#if (%random( 1, @st_relay)=1) {
      //Need to change intensity of the stutter when it is a question or exclamation point at the end of the sentence
      $s_word = %concat( $matched, "-", $matched, "-", %i)
      $sentence = %replaceitem( $s_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>
    <arglist>$channel,$input</arglist>
  </func>
</cmud>

Now here is the new stutter alias:
Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="stu">
    <value>#local $channel, $input
$channel = %1
$input = %params( 2)
#send @SpeechType($channel,$input)</value>
  </alias>
</cmud>


Now here it the trigger that isn't working correctly:
Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger type="Command Input" priority="210">
    <pattern>^say(*)</pattern>
    <value>#local $input
$input = %1
#send @SpeechType(say,$input)</value>
  </trigger>
</cmud>

When I try the Command Input trigger it runs an infinite loop. I am confused.
_________________
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: Fri Oct 22, 2010 4:44 am   
 
You'll need a #noinput command, else you'll get doubled commands sent to the game. That probably won't fix the infinite loop, so try unchecking the Trigger on Trigger option.
_________________
EDIT: I didn't like my old signature
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Oct 22, 2010 4:46 am   
 
#oninput I thought that when you choose Command Input type trigger it would make it an oninput trigger. Can you help me understand.
_________________
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: Fri Oct 22, 2010 5:03 am   
 
Here's a couple of examples:

#oninput {^test$} {#send look}

#oninput {^test$} {#noinput;#send say test}

The first example should result in two commands being sent to the game--"test" and "look"--while the second example should only result in one command being sent--"say test". This is because command input triggers don't do a single thing with the original command that fires them.
_________________
EDIT: I didn't like my old signature
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Oct 22, 2010 3:04 pm   
 
Okay. I had it correct but the removed the trigger on trigger for oninput trigger. Here is the code, but for some reason it is sending it twice.
Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger type="Command Input" priority="1" trigontrig="false" enabled="false">
    <pattern>^say(*)</pattern>
    <value>#local $input
$input = %1
#send @SpeechType(say,$input)</value>
  </trigger>
</cmud>
_________________
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
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Oct 22, 2010 4:46 pm   
 
You need to add the #NOINPUT command to your Command Input trigger to prevent the original command line from being sent to the MUD.
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Oct 22, 2010 5:03 pm   
 
Zugg wrote:
You need to add the #NOINPUT command to your Command Input trigger to prevent the original command line from being sent to the MUD.


So all I need to add is #NOINPUT after the function call? I thought the Command Line Type trigger meant is was an oninput type.
_________________
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
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Oct 22, 2010 5:07 pm   
 
Yes, "Command Input" means it is an #oninput type. So that is correct. You should add the #NOINPUT command at the end of your trigger after the #send command. Did you click on the link for #oninput and read the help file?
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Oct 22, 2010 5:38 pm   
 
Hey I just noticed something. As part of my script you can do emphasis say for instance:
Code:
stu say "(while smiling)" You make me laugh.

will show in the mud as:
Code:
You say, while smiling, You make me laugh.


But now I don't need the quotes around the emphasis with the command line trigger for say, which doesn't use the alias and just calls the function.
How can I get the alias to do the samething so I don't need to put the quotes around the parenthesis? Any ideas.
I would like to give the user the option of using the alias or just using the command line trigger which will be turned on or off by a button or mxp link (haven't decided yet.)
_________________
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
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Oct 22, 2010 6:02 pm   
 
Zugg wrote:
Yes, "Command Input" means it is an #oninput type. So that is correct. You should add the #NOINPUT command at the end of your trigger after the #send command. Did you click on the link for #oninput and read the help file?


I just realized you were saying NOINPUT NOT ONINPUT..... I must be loosing it. Very Happy

Thanks Zugg.
_________________
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
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Sat Oct 23, 2010 3:04 am   
 
darmir wrote:
Hey I just noticed something. As part of my script you can do emphasis say for instance:
Code:
stu say "(while smiling)" You make me laugh.

will show in the mud as:
Code:
You say, while smiling, You make me laugh.


But now I don't need the quotes around the emphasis with the command line trigger for say, which doesn't use the alias and just calls the function.
How can I get the alias to do the samething so I don't need to put the quotes around the parenthesis? Any ideas.
I would like to give the user the option of using the alias or just using the command line trigger which will be turned on or off by a button or mxp link (haven't decided yet.)


I hope someone can help me figure this one out. I would love not to have to put quotes around the parentheses.
_________________
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: Sat Oct 23, 2010 3:30 pm   
 
If you insist on using parentheses then you have no choice but to put quotes around them to avoid CMud from using them as evaluation.

If you stop using parentheses then you can use some other delimiter so that the user only has to type the text used instead of both the text and the syntax:

stu say, while smiling, You make me laugh.

You will need to remove your named parameters and rework how you assign your variables, and if the game requires the emphasis to actually have () around it you will need to provide for that as well. Here's an example to help you see what I mean:

Code:
#function stu {
  // stringlist-ify the sent parameters
  $raw = %replace(%params(1),", ","|")
  // set up individual parameters for processing
  $channel = $raw.1
  #if ($raw.3 != "") {
    $emphasis = " ("$raw.2") "
    $speech = $raw.3
  } {
    $emphasis = " "
    $speech = $raw.2
  }
  // do parameter processing work here (not shown in this example)
  // put together and return the result
  #return %format("&s&s&s",$channel,$emphasis,$speech)
}
_________________
EDIT: I didn't like my old signature
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Oct 25, 2010 5:06 pm   
 
To deal with the parenthesis, mark your Command Input trigger as a "Trigger on Prompt" and turn off the "Trigger on Newline" option. Making the Command Input trigger a "prompt" trigger will cause it to fire *before* CMUD parses the command line (and converts the parenthesis).
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