|
tiornys Newbie
Joined: 14 Feb 2013 Posts: 1 Location: Colorado
|
Posted: 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! |
|
|
|
rozdwojeniejazni Wanderer
Joined: 13 Aug 2011 Posts: 74
|
Posted: Thu Feb 14, 2013 9:00 am |
This will work
Code: |
#alias maketrigger {#trigger "triggerid" %-2 %1} |
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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.
|
|
|
|
rozdwojeniejazni Wanderer
Joined: 13 Aug 2011 Posts: 74
|
Posted: 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} |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: 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. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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.
|
|
|
|
|
|