|
Tygerhart Novice
Joined: 04 Oct 2001 Posts: 43 Location: Canada
|
Posted: Thu Jan 29, 2004 9:49 pm
RP script help? |
Hi all!
I'm hoping someone can help with this little problem. I need a script to change the text I'm writing when I "say" or "tell" someone on my MUSH something.... here's an example of what I mean.
Raw Text say It's a pleasure to meet you.
MUSH/MUD Output Bob says It's a pleasurrrre to mmmeet you. Mmmm?
Essentially I want any instance of the letter "R" or "M" to be replicated randomly to 3 or 4 extra letters in a word and always finishing off the line with "Mmmm?".
The Reason
I would have to be flying a complex ship and responding to orders in character. Having to manually type out the extra "r"s, "m"s and the "Mmmm?" takes up valuable time I need to respond.
Yeah, I know, maybe I shouldn't have made a character with a speech impediment, but I know that already and it's too late.
Thanks in Advance,
Tygerhart |
|
|
|
Rorso Wizard
Joined: 14 Oct 2000 Posts: 1368
|
Posted: Thu Jan 29, 2004 10:14 pm |
Something like this might work:
The talk alias replaces the appropiate letters with the "extra letters" by using the translate function.
#ALIAS talk {#show %concat(%subregex( %0, "(r|R)|(m|M)", "@translate(~%0, %random(3,4))"), " Mmmm?"}
The translate function builds up a string with a specific letter repeated a specific amount of times.
%1: Letter to be repeated
%2: Amount of repeats.
#VARIABLE translate {%if( %2>0, %concat( %1, @translate(%1, %eval(%2-1))), "")}
Edit: If you want it to translate "Many things happening" -> "Mmmany things..." instead of "MMMany things ..." use this code for the translate function:
%if( %2>0, %concat( @translate(%1,%eval(%2-1) ), %if( %2>1, %lower( %1), %1)), "")
Have fun roleplaying |
|
|
|
Tygerhart Novice
Joined: 04 Oct 2001 Posts: 43 Location: Canada
|
Posted: Fri Jan 30, 2004 12:24 am |
quote: Originally posted by Rorso
Something like this might work:
Thanks Rorso!
It worked with some jinking around. Now I just need some fine tuning. Maybe you or someone else can help me tweak it a bit.
Here's how it's working now
#ALIAS t
tt {
%subregex( %0, "(r|R)|(m|M)", "@translate(~%0, %random(3,4))")
} Mmmmm?
This works well but here's where I need the tweak...
#ALIAS tt ("tt" is the MUSH command for "table talk", it only accepts "tt".)
~tt {
%subregex( %0, "(r|R)|(m|M)", "@translate(~%0, %random(3,4))")
} Mmmmm?
Can you see the problem? I tried using the tilde (~) in front of the value's "tt", but that shuts the whole thing off. Any suggestions how to just shut the "tt" off in the value and not the entire value? (Hope this makes sense.)
Thanks again,
Tygerhart |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Fri Jan 30, 2004 12:45 am |
#ALIAS tt {~tt %concat(%subregex( %0, "(r|R)|(m|M)", "@translate(~%0, %random(3,4))"), " Mmmm?"}
Move the ~tt inside the {} |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Jan 30, 2004 4:03 am |
Also %0 is not supported and may not work in future versions. Use %-1 instead.
|
|
|
|
|
|
|
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
|
|