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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Mon Nov 05, 2007 3:59 pm   

Nickname Command
 
In the mud I play there is a command called nickname . You use it like nickname 'dun don't . That means when the word don't is typed in, 'dun will replace it. Problem is, what if don't is accompanied with a punctuation mark? For instance, what if I typed in Billy does it, but I don't. . That end don't won't get replaced. I have to set up a whole other nickname with the period at the end.

Is there a way for me to set it up in Zmud so that for every instance of don't (in this example) it gets captured and replaced with 'dun?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Nov 05, 2007 4:29 pm   
 
While I hate accents on principle, there are a couple of ways to do this. The simplest that I can think of is with an oninput trigger:

#oninput {^} {#gag;#send %replace(%line,"don't","dun")}

You can add more replacements like this:

#oninput {^} {#gag;#send %replace(%replace(%line,"don't","dun"),"whatever","something")}

But remember that this will change it every single time the word "don't" is sent to the MUD from any source. This is potentially a bad thing (since your character wouldn't use his or her accent in, say, a letter) and so you might want to create a custom function like so:

#funcion accent {%replace(%-1,"don't","dun")}

You can add new replaces the same way as you do with the trigger. You then use this like so:

say @accent(I don't like your face, punk)

and the function will replace things in the brackets that you've told it to. That way, you can omit the function when you don't want to use your accent.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Tue Nov 06, 2007 4:48 pm   
 
So I put this

Quote:

#function accent {%replace(%-1,"don't","dun")}



into Zmud. Then I typed

Quote:

say @accent(I don't like your face, punk)



and got this

Quote:

You chortle in a maniacal tone: @accent (I don't like your face, punk)



What did I do wrong?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Nov 06, 2007 5:03 pm   
 
You put a space between the t in accent and the bracket, it would appear. It's working fine for me, however - if your string contains commas, you must put the whole string in "quotes". I should've mentioned that before.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Tue Nov 06, 2007 5:13 pm   
 
I'd be tempted to use an alias for this rather than an oninput trigger so you can easily control exactly when you use the accent.
using Fang's example, something like
#ALIAS accent {say %replace(%-1,"don't","dun")}

If you wanted it to replace say then
#ALIAS say {~say %replace(%-1,"don't","dun")}
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Nov 06, 2007 5:30 pm   
 
That's certainly a possibility, but both of those only work for #say. The function I suggested can be used with any channel. You could make the alias a bit more versatile with something like

#ALIAS accent {#exec {%1 %replace(%-2,"don't","dun")}}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Tue Nov 06, 2007 6:49 pm   
 
I'm telling you, i've inputed it into the command line just like you said. When I type say @accent(I don't like your face, Punk) I get You chortle in a maniacal tone: @accent(I don't like your face, Punk).

I'll give the other suggestions listed a try.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Nov 06, 2007 6:53 pm   
 
Oh, balls. There's a typo in my post - I missed out the t in function Embarassed Add it in and try again, and remember what I said about commas.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Tue Nov 06, 2007 6:55 pm   
 
This works

#ALIAS say {~say %replace(%-1,"don't","dun")}

but how do I add a whole list of words and their replacements? In case you are wondering, i'm playing a dwarf and trying to create a list of words so he has an accent but I don't have to worry about typing in the accented words every time.
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Tue Nov 06, 2007 6:56 pm   
 
I did add the T in function. Still no go.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Nov 06, 2007 7:03 pm   
 
To paraphrase myself, you can add more replacements like this:

%replace(%replace(%-1,"don't","dun"),"whatever","something")
%replace(%replace(%replace(%-1,"don't","dun"),"whatever","something"),"omg","lol")

Just keep adding more %replace functions around what you have already, with the function you have already as the first parameter.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Tue Nov 06, 2007 10:20 pm   
 
If you've got a lot of things to replace you could always try using a key/val variable

set it up using

#VAR accent {}
#ADDKEY accent {hello} {heya}
#ADDKEY accent {blah} {tum te tum}
#ADDKEY accent {don't} {dun'}

then you can use the alias to loop through that list
#ALIAS accent {$temp = %-2;#loopdb @accent {$temp = %replace($temp,%key,%val)};%1 " " $temp}

Then if you type
accent say hello buddy, don't do that blah blah eh

it'll send
say heya buddy, dun' do that tum te tum tum te tum eh
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Nov 06, 2007 10:26 pm   
 
zMUD general discussion, Guinn ;)

To get the same effect in zMUD, your alias will need to be

#ALIAS accent {temp = %-2;#loopdb @accent {@temp = %replace(@temp,%key,%val)};%1 " " @temp}

You may find this to be slower (because it's writing to a variable a lot), but probably not noticable so, and it's quite a bit neater.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Tue Nov 06, 2007 10:36 pm   
 
whoops, forgot to even check the forum
well, the moral of the story is that everyone should just buy CMUD right? :)
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Wed Nov 07, 2007 11:57 am   
 
My thanks, Guinn. It appears your way seems to work the best. Thank you all so much for your help.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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