|
admonius Newbie
Joined: 12 Jul 2001 Posts: 9 Location: USA
|
Posted: Mon Nov 11, 2002 8:17 am
Replacing spaces |
Im looking to replace spaces with an underscore....heres the situation:
In my current MUD, my race has a speech mod, for when I enter text.
I type:
'I hate this speech mod
Mud shows this:
You quickly say 'Ihatethisspeechmod.'
Basically, I want to replace the spaces with and underscore, like this:
I type:
'I hate this speech mod
zMUD sends:
'I_hate_this_speech_mod
Mud then shows this:
You quickly say 'I_hate_this_speech_mod.'
I have tried using %replace and #SUB, but with no success...any help would be appreciated.
Admonius
Go Big Red! |
|
|
|
Castaway GURU
Joined: 10 Oct 2000 Posts: 793 Location: Swindon, England
|
Posted: Mon Nov 11, 2002 8:56 am |
*How* have you tried %replace?
(should work, methinks)
Lady C. |
|
|
|
Tarn GURU
Joined: 10 Oct 2000 Posts: 873 Location: USA
|
Posted: Mon Nov 11, 2002 8:58 am |
How about:
#alias s {say %replace( %-1, " ", "_")}
commands like "s hello goodbye 1 2 3 4 5" will be picked up by the alias and the mud will get "say hello_goodbye_1_2_3_4_5"
The %-1 argument to an alias tells it to use the rest of the line.
Tested 6.37a, it should work in 6.16.
-Tarn |
|
|
|
admonius Newbie
Joined: 12 Jul 2001 Posts: 9 Location: USA
|
Posted: Mon Nov 11, 2002 8:59 am |
I have tried this:
#TRIGGER {'(*)} {#send %replace( %1, %s, _}
I have also tried to use the same thing with an alias.
Admonius
Go Big Red! |
|
|
|
admonius Newbie
Joined: 12 Jul 2001 Posts: 9 Location: USA
|
Posted: Mon Nov 11, 2002 9:00 am |
Tarn got it
Thank you all
Admonius
Go Big Red! |
|
|
|
admonius Newbie
Joined: 12 Jul 2001 Posts: 9 Location: USA
|
Posted: Mon Nov 11, 2002 9:06 am |
quote:
OK, one last thing...when I use a comma it cuts the sentance off after it
Use "%-1" instead of %-1 in the replace. You'll still get caught by the semicolons, though- is that a problem?
-Tarn
(I'm sorry, I slipped and edited your post instead of replying to it)
Edited by - Tarn on 11/11/2002 02:30:18 |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Nov 11, 2002 7:02 pm |
Since you're using a function (%replace), commas get interpreted as the end of a function parameter. To avoid this, use delimiters.
#alias s {say %replace( {%-1}, " ", "_")}
LightBulb
Senior Member |
|
|
|
|
|