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
bozo
Beginner


Joined: 15 Jun 2004
Posts: 11

PostPosted: Thu Jul 22, 2004 10:42 am   

Alias arguments
 
Hi

I have an alias which is called by a trigger simmilar to the following

(*) some text (%w)
myalias %1 %2

the problem is that %1 in myalias is not * but the first non space word of *, ie * is truncated. I need the whole of * to be passed to the alias as %1, where * includes spaces. Any ideas?

thanks.
_________________
Reply with quote
geniusclown
Magician


Joined: 23 Apr 2003
Posts: 358
Location: USA

PostPosted: Thu Jul 22, 2004 3:52 pm   
 
Quote:
#TR {^(*) some text (%w)} {myalias {%1} %2}

First off, by doing ^(*), it will make sure that * starts at the beginning of the line.

Second, by putting {%1} in the alias, it won't expand the * so that it thinks the first word of * is %1, second word of * is %2, etc. Note that since %2 is captured as a single word with %w, you know it won't expand, so you can safely use %2 without the {}.

Does that make sense? It's still early...
_________________
.geniusclown
Reply with quote
bozo
Beginner


Joined: 15 Jun 2004
Posts: 11

PostPosted: Thu Jul 22, 2004 6:17 pm   
 
let me put it another way.

I have an alias which i would like to pass 2 arguments to. The first argument must be able to include spaces and the second argument is either yes or no.

In other words how do you pass a string to an alias using * in the trigger.
_________________
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Thu Jul 22, 2004 7:02 pm   
 
You had the right trigger pattern to begin with, but perhaps a more specific example than "some text" would help.

If you have a trigger like the following,

#TRIGGER {(*) in the (%w)} {#echo {First: %1, Second: %2}} "" {notrig}

and you see the message,

You have 20 gold in the bank.

you'll get %1 = "You have 20 gold" and %2 = "bank".

If you see the message (bad example, just to illustrate a point),

You have in the bank 20 gold in the bank.

you'll get %1 = "You have in the bank 20 gold" and %2 = "bank".

This means that either your trigger settings are configured improperly or you have made some typo in your command alias.
Reply with quote
bozo
Beginner


Joined: 15 Jun 2004
Posts: 11

PostPosted: Thu Jul 22, 2004 7:56 pm   
 
Larkin,

what you say is indeed true, but now put your #sh %1 in the alias... get my drift

eg

#TRIGGER {(*) in the (%w)} { myalias %1 %2}} "" {notrig}

myalias
#sh %1

as geniusclown says it wont expand it.
_________________
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Jul 22, 2004 9:38 pm   
 
Use double-quotes to include leading spaces.
#TR {(*) idiotic obfuscation (%w)} {myalias "%1" %2}
#AL myalias {#SHOW %1;#SAY %2}
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: Thu Jul 22, 2004 10:45 pm   
 
Why not just reverse the order of the parameters, and then use %1 for the yes/no and %2- for the other thing in the alias? Seems a lot simpler and more robust.
Reply with quote
bozo
Beginner


Joined: 15 Jun 2004
Posts: 11

PostPosted: Fri Jul 23, 2004 6:52 am   
 
Theragil now theres someone with lateral thinking... but %1 or %2 doesnt pass strings so wont work anyway you look at it!

Lightbulbs course of action which works a treat.

Thanks for the help guys!
much obliged.
_________________
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: Fri Jul 23, 2004 6:04 pm   
 
That's why it would be %-2 instead of just %2.
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