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
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Jun 11, 2008 4:02 pm   

In-line alias...
 
Hello. So, for this post, my question is: is it possible to create an in-line alias? By that, I mean an alias that is detected in a line and acted on. Traditionally, an alias is only activated if it is alone or precedes an argument. What I want is something that the client will recognize no matter where it is in the line and act on. No parameters, purely a substitution of characters. Something like {g being translated into %xg, or {G into %xh%xg... etc. So that, if I had the following sent to the game:


ntp raises an eyebrow at the request, a pipe being a more personal object to him. He looks down at it for a moment, stroking the long end of the pipe and nods, deciding to be gentlemanly. He stands up and offers a bow, handing the pipe to Jemstone, "{gWhy of course, but not too long!{x" He chuckles slightly, folding his arms, his gloved hands tapping on his forearms.

could be turned into:

@emit %tKjabbar raises an eyebrow at the request, a pipe being a more personal object to him. He looks down at it for a moment, stroking the long end of the pipe and nods, deciding to be gentlemanly. He stands up and offers a bow, handing the pipe to Jemstone, "%xgWhy of course, but not too long!%xn" He chuckles slightly, folding his arms, his gloved hands tapping on his forearms.

For extra kudos:
Finding a way to make a "smart" alias that already does some of it's own checking, so that something like...

ntp raises an eyebrow at the request, a pipe being a more personal object to him. He looks down at it for a moment, stroking the long end of the pipe and nods, deciding to be gentlemanly. He stands up and offers a bow, handing the pipe to Jemstone, "Why of course, but not too long!" He chuckles slightly, folding his arms, his gloved hands tapping on his forearms.

would turn into:
@emit %tKjabbar raises an eyebrow at the request, a pipe being a more personal object to him. He looks down at it for a moment, stroking the long end of the pipe and nods, deciding to be gentlemanly. He stands up and offers a bow, handing the pipe to Jemstone, "%xgWhy of course, but not too long!%xn" He chuckles slightly, folding his arms, his gloved hands tapping on his forearms.

Essentially the alias would do a few things:
It would check to find a beginning " and replace it with "%xg, it would note that it found a beginning " making the next " the closing, and replacing it with %xn" and the client would only do these replacements within the alias.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Wed Jun 11, 2008 4:16 pm   
 
You need to use an input trigger. #ONINPUT
_________________
Taz :)
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Jun 11, 2008 4:22 pm   
 
Yes. It's called an oninput trigger. You can use #noinput to replace the line with some other text (like a normal alias), or just run some code silently as commands are entered, or you can use #sub to change parts and leave other bits intact, like #oninput {fang} {#sub {my lord and master}} ;)
_________________
Rorso's syntax colouriser.

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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Jun 11, 2008 4:46 pm   
 
The problem with #oninput is that it wants to replace the whole line. Is there a way to change that?

#oninput test {~{g} {~%xg}

p Kja=Test with {gthis%xn

is sent as:
%xg

Also, is #oninput the answer for a smart alias?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Jun 11, 2008 5:27 pm   
 
Because you're not doing it like I showed you. Use #sub as in my example.

#oninput test {~{g} {#sub {~%xg}}

is all it takes.

It's interesting, though, that your example replaces the command rather than sending them both. Bug?

Oh, and it depends what you want to do with your smart alias. It'd certainly be very easy to do with oninput triggers, something like:

#oninput {\"(.+?)\"} {#sub {%concat(~","%xg",%1,"%xn",~")}}

or thereabouts.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Jun 11, 2008 5:39 pm   
 
%line, %lastcom and %lastinput should all help with what you want.
_________________
Asati di tempari!
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Jun 11, 2008 5:40 pm   
 
the trigger in the alias? Or making the trigger the alias, and the pattern would be what I wanted to type for the alias?

Oh, and how do I make it case sensitive? So I can have {G and {g as different...
_________________
Listen to my Guitar - If you like it, listen to more

Last edited by chamenas on Wed Jun 11, 2008 5:44 pm; edited 1 time in total
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Jun 11, 2008 5:42 pm   
 
The latter.
_________________
Rorso's syntax colouriser.

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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Jun 11, 2008 5:55 pm   
 
Thanks, I added something to the previous past as well.

So...

instead of

#al ntp {@emit %tKjabbar %params}

#oninput {\"(.+?)\"} {#sub {%concat(~","%xg",%1,"%xn",~")}} ? but that only searches for the " ", so perhaps it should be a function within the alias?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Jun 11, 2008 6:05 pm   
 
Yes, you'll perhaps want to use that with a %subregex function in an alias or an oninput trigger. But it's very possible, yes.

And case sensitivity is as simple as turning on the case sensitivity option for the trigger.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)

Last edited by Fang Xianfu on Wed Jun 11, 2008 6:08 pm; edited 1 time in total
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Jun 11, 2008 6:08 pm   
 
Right, is there a way to turn it on in the command line form, however?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Jun 11, 2008 6:08 pm   
 
Eh?
_________________
Rorso's syntax colouriser.

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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Jun 11, 2008 6:26 pm   
 
Is there a way to make

#oninput gray {~{w} {#sub {~%xw}} {color substitutions}

case sensitive, just by using that command line form. As opposed to using check boxes.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Jun 11, 2008 8:19 pm   
 
#oninput gray {~{w} {#sub {~%xw}} {color substitutions} {case}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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