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
tiornys
Newbie


Joined: 14 Feb 2013
Posts: 1
Location: Colorado

PostPosted: Thu Feb 14, 2013 8:02 am   

Alias to create trigger possible?
 
Hello! I would like to create an alias that would create a trigger using the alias input. Something like the following:
#alias maketrigger {#trigger {%-2} {%1}}

I've tried several different combinations, but I can't find a way to get CMUD to expand a variable reference within the trigger pattern field. Expanding variables in the commands field works with no problems.

For example, with the above alias, if I type:

maketrigger dance the lady dances across the room

I want the alias to create a trigger with pattern "the lady dances across the room" and command "dance". Instead, I get a trigger with pattern "%-2" and command "dance".

Is it possible to do what I want, or am I out of luck?

Thanks for any help, and sorry if I've overlooked an obvious reference somewhere!
Reply with quote
rozdwojeniejazni
Wanderer


Joined: 13 Aug 2011
Posts: 74

PostPosted: Thu Feb 14, 2013 9:00 am   
 
This will work
Code:
#alias maketrigger {#trigger "triggerid" %-2 %1}
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Feb 14, 2013 1:50 pm   
 
As an explanation, the {} in your original alias was acting like quotation marks, preventing expansion of the variables.
Reply with quote
rozdwojeniejazni
Wanderer


Joined: 13 Aug 2011
Posts: 74

PostPosted: Thu Feb 14, 2013 4:28 pm   
 
Oh, so maybe you can explain something I never understood. Why won't this work?
#alias maketrigger {#trigger %-2 %1}
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Feb 15, 2013 4:00 pm   
 
You need to actually do:

Code:
#ALIAS maketrigger {#EXEC %concat("#TRIGGER {",%-2,"} {",%1,"}")}


in order for it to work.

As an explanation for your second option, it won't work because there is no definition to what the actual trigger is and what commands you want it to do, despite how it may appear. CMUD (and zMUD) require the {} around the two settings to know how to interact with it. Without it, as in your second example, you're just sending:

#TRIGGER I'm a little teapot Short;Stout

and CMUD wouldn't know what to do with it.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Feb 15, 2013 9:28 pm   
 
Basically, if you don't use the braces {} in #TRIGGER to mark the pattern and the commands, it will assume the first parameter is the trigger ID, the second parameter is the pattern, etc. The purpose of the curly braces in #TRIGGER is to allow the ID to be optional. But that doesn't work in your alias, because the curly braces in the alias value are being treated as quotation marks.
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