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


Joined: 16 Oct 2001
Posts: 22

PostPosted: Tue Oct 16, 2001 1:23 am   

Optional match in triggers
 
Is it possible to put an optional match in a trigger so it would match, say:
Hello there lad.
And:
Hello lad.
Without using {there lad.|lad.}, in other words to specify that the 'there' is optional. I've tried {there |} and {there |%null} but it just doesnt seem to work :(
Thanks

Roxy Bee
Reply with quote
Shylmysten
Wanderer


Joined: 18 Sep 2001
Posts: 93
Location: USA

PostPosted: Tue Oct 16, 2001 12:37 pm   
 
Hello there lad.
And:
Hello lad.



#tr {Hello%*lad} {do/say whatever}


%* matches any amount of spaces, characers, or punctuation

You could also use


#tr {%*lad} {do/say whatever}


In case some said Greetings Lad, or well met, lad

I would only suggest one thing, Since this is obviously from a say, or channel, I would put the channel it is broadcasted over, in the trigger, otherwise it will match ANY occurance of lad, such as, a character named Vlad walks buy, your trigger will fire.....if a word in the room description ends with lad, it will fire your trigger.....thus


#tri {(%w) says%*lad} {say hello %1;noogie %1}



-Shyl-
Reply with quote
Darker
GURU


Joined: 24 Sep 2000
Posts: 1237
Location: USA

PostPosted: Tue Oct 16, 2001 2:07 pm   
 
Just to be safe, I've got to recommend against use of %* for this. That wildcard combination captures everything, even punctuation. So if some joker sent you

Hello ;grin;yell The immortals here are so stupid!;remove all;drop all;quit; lad

Your command would very likely execute all the parts in the middle and You'd be in quite a pickle.

If you're not expecting punctuation within the section between Hello and lad just use *. As in Hello* lad.

Much safer, since it won't match the ;'s that could really get you into trouble.



zMUD 6 Online Help: All the power you'll ever need.
Reply with quote
Shylmysten
Wanderer


Joined: 18 Sep 2001
Posts: 93
Location: USA

PostPosted: Tue Oct 16, 2001 2:20 pm   
 
how would it execute those commands? It just setting up a match with that not looking for a variable......

(%*) would be something that could be executed
%* is just a pattern match
Also I used the (%w) for a word match and %1 in their respective positions, how would %* be executed

#tri {(%w) says%*lad} {say hello %1;noogie %1}

Joe says, hello drop all yer equipment lad!

That doesnt matter, what is being exected is the word
%1 = Joe
%* = %* it has no variable withing the command line

Check the pattern matching, what is in the matched box shows this

%1: abc

There is no %2 cause the ()'s werent around it

I could be wrong, but I use this all the time, and have never had a problem
Reply with quote
Darker
GURU


Joined: 24 Sep 2000
Posts: 1237
Location: USA

PostPosted: Tue Oct 16, 2001 2:35 pm   
 
True, you've got to be doing something with the saved match for it to be vicious - like saving it to a variable, etc. I overlooked that you're not doing that (way to go me!) when I saw what wildcard you used in the trigger. I'm jumpy like that. Especially with this wildcard.

The trigger was good, and I wasn't trying to say there was anything wrong with it, except to say that %* can be evil. It can frequently be replaced with a safer version.

From a "security for newbies" standpoint, it's important to recognize what the %* wildcard is capable of. * would work just as well (excepting punctuation) and doesn't pose the same risk. In the "Hello (whatever) lad" case it'd be fine to use *.

If a newbie saw that %* is what's used to match anything they want, and () was how to use it in a command, that's two thirds of a dangerous combination. One wrong %1 and they've got a gaping hole in their settings that can be used to their detriment. They could understandbly get the impression zMUD's unsafe for their use. If that were the case, they'd not have been served very well by the advice they get here, and that's all I'm trying to avoid.



zMUD 6 Online Help: All the power you'll ever need.
Reply with quote
jkazos
Beginner


Joined: 10 Feb 2002
Posts: 14

PostPosted: Wed Apr 03, 2002 6:09 pm   
 
That's a way to do it, but the core question was never answered. How would one get a trigger to match *exactly* these two things and nothing else?

Hello there lad.
Hello lad.

Let's pretend `something` is the syntax to say that that something is optional. I would imagine this trigger.

#trigger {^Hello (`there `)lad.$} {#if {"%1" = "there "} {...} {...}}
Reply with quote
jkazos
Beginner


Joined: 10 Feb 2002
Posts: 14

PostPosted: Wed Apr 03, 2002 6:52 pm   
 
Nevermind, I figured it out. You can use a RegEx trigger for it.

#trigger {Hello (my )? lad.} {#show a}

This works for "#show Hello lad." and "#show Hello my lad.". Now, I ask: Can other trigger types (WithinLines, ReParse, Etc.) be made RegEx too?
Reply with quote
heidi
Newbie


Joined: 04 May 2002
Posts: 1

PostPosted: Wed Apr 03, 2002 7:19 pm   
 
The RegEx expression you included in the post above didn't work on my version of zMud (6.16) so I assume you are using the new beta version. This is what I could get working on my version:

#trigger {Hello(%*)lad.} {#If %ismember("%1",{" "|" there "|" my "}) {#show Good} {#show Not Good}}

Yeah, it's a bit hokey but it does do the job. One nice thing is you could use this with the #Case command to react differently to different parameters.

El_Dickman
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