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


Joined: 07 Feb 2005
Posts: 4

PostPosted: Mon Feb 14, 2005 5:29 am   

Creating a trigger with an alias
 
I'm trying to make an alias that will create a special sort of trigger for me.
"end" is an alias that i want to be performed whenever one of these triggers fires.

Here's what I have for the alias:
#ALIAS quick {#trigger {%1} {%2; end} "Quick"; #class Quick 0}

The idea is for you to be able to type this:
quick {string to be matched} {#do something}

and have it create a trigger that's in a disabled class that looks like this:
#trigger {string to be matched} {#do something; end} "Quick"

The problem is in order to seperate the two arguments to the alias they have to be enclosed in {} or "" or () or SOMETHING, but the enclosing characters are always included in the trigger, creating something like this:
#trigger {{string to be matched}} {{#do something}; end} "Quick"

And the nested stuff either won't executed correctly or creates syntax errors.

Help? Please?
Reply with quote
akumasama
Newbie


Joined: 07 Feb 2005
Posts: 4

PostPosted: Mon Feb 14, 2005 7:56 am   
 
For the curious, this seems to work:

#ALIAS quick {
#VAR tmp1 %1; #VAR tmp2 %2
#trigger {<@tmp1>} {<@tmp2>; end} "Quick"; #class Quick 0
}

If there's any more elegant way of doing it, I'd appreciate hearing about it though.
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Mon Feb 14, 2005 6:50 pm   
 
I dont know if its more elegant but here's another way

Code:
#ALIAS quick {#exec {#trig {%literal(%1)} {%literal(%2);end} quick}}
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Feb 14, 2005 10:18 pm   
 
A couple %remove()'s or similar functions would do the trick as well, but that might turn out to be slower than desired.
_________________
EDIT: I didn't like my old signature
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Feb 14, 2005 10:26 pm   
 
If you want to handle a couple variables, you could use a %match() function on the entire parameter list:

#noop %match("%q(*)%q %q(*)%q",@trigger.pattern,@trigger.code)
#trigger {@trigger.pattern} {@trigger.code}

Dunno if %q will pick up on the brackets, so you might need to do that manually via a pattern range ([]) or multiple %match() functions.
_________________
EDIT: I didn't like my old signature
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Mon Feb 14, 2005 11:54 pm   
 
Code:
#ALIAS quick {#exec {#trig {%literal(%1)} {%literal(%2);end} quick "" %literal(%3)}}

Lets you add the options trigger options afterward, so you can make it a regex trigger, or perhaps case insensitive.

quick {(\w+) says 'hello'} {say hi there %1} {case|regex}

Would make a case sensitive,regular expression,to say hi to the person that says hello to you, and also invoke the end alias.
Because of the %literal() you just write it exactly as you would make a trigger directly using the #trigger command except of course that the classname option is not needed.
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
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