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


Joined: 11 Jun 2003
Posts: 22
Location: Moldova

PostPosted: Wed Jun 11, 2003 11:15 am   

Another #TRIGGER question (pattern matching)
 
I have a trigger with the following pattern:
You (*) {a|an|the} (*) ({solidly|forcefully})

It matches a string, when i hit someone, like this:
You hit a white seagull forcefully.
In this case everything is okay, variables output is nice. %1 = hit, %2 = white seagull and %3 = forcefully.

But when i hit someone with description like this:
You hit a shueball player in a white shirt solidly.
The trigger working not as i want it to work. The output is this %1 = hit a shueball player in, %2 = white shirt, %3 = solidly.

The question is this. How i can make a trigger to match first "a" or "an" or "the" in the string?
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Wed Jun 11, 2003 3:27 pm   
 
You need to force it to match from yhe beginning of the trigger with "^" this should resolve your problem.

#trigger {^You (*) {a|an|the} (*) ({solidly|forcefully})} {something}

megamog75
Keeper of the only printable help files for Zmud.
Reply with quote
AlT
Beginner


Joined: 11 Jun 2003
Posts: 22
Location: Moldova

PostPosted: Wed Jun 11, 2003 3:48 pm   
 
Thanks for answer megamog75, however no, it don't solves the problem. I tried it before and it behaves just like without ^ sign. With ^ sign it mathes last occurence of the "a" word anyway.

Anybody have any other suggestions? Help please.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Jun 11, 2003 4:10 pm   
 
* matches the longest possible string. There's no way to force it to do anything else. Therefore, you'll need to come up with a pattern which doesn't rely on * for the first wildcard.

LightBulb
Advanced Member
Reply with quote
AlT
Beginner


Joined: 11 Jun 2003
Posts: 22
Location: Moldova

PostPosted: Wed Jun 11, 2003 4:36 pm   
 
Thanks for explication LightBulb. However i have another question then.
First * mathes in my case one OR two words. Is there a way to match and save a pattern which may be one or two words divided by spaces, other than using *?

I know this can be done with "String List" variable, however i need this variable to be a "Data Record" variable and data records can't be used for pattern matching directly.

Any other sugesstions, please?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Jun 11, 2003 7:21 pm   
 
Patterns of one or two words are quite easy to match, once you get over the idea that it has to be done by a SINGLE trigger.
You (%w) {a|an|the} (*) ({solidly|forcefully})
You (%w %w) {a|an|the} (*) ({solidly|forcefully})

LightBulb
Advanced Member
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Jun 11, 2003 10:03 pm   
 
Record variables can be used directly for matching in patterns. The match is done based on the keys.
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Thu Jun 12, 2003 5:07 am   
 
quote:

Is there a way to match and save a pattern which may be one or two words divided by spaces, other than using *?



You could also use the * and then %replace the "space"or" " with "|"=enter and then only use either %item 1 or 2.
this method would allow for your trig to have 1 2 3 or more words in it but because you know your key word is the first one always or 2nd or 3rd you could then weed out what you don't want.

Just a suggestion.

megamog75
Keeper of the only printable help files for Zmud.
Reply with quote
AlT
Beginner


Joined: 11 Jun 2003
Posts: 22
Location: Moldova

PostPosted: Thu Jun 12, 2003 9:33 am   
 
Thanks to all, for the help. I made it, it's working now. ;)
Both suggestions from megamog75 and LightBulb was usefull. Thanks.

And to Vijilante. I still can't make a data record variable which can be used in the pattern directly. The trigger don't match it. :( At least in zMUD 6.16. May be i should upgrade it? Or of it should work in 6.16 may be you can show a brief example of respective variable and trigger to match data records?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jun 12, 2003 11:04 am   
 
Oh, your still using 6.16 in that case they can't be used.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Jun 12, 2003 11:30 am   
 
You should upgrade anyway.

Kjata
Reply with quote
AlT
Beginner


Joined: 11 Jun 2003
Posts: 22
Location: Moldova

PostPosted: Thu Jun 12, 2003 11:41 am   
 
The main reason why i still using 6.16 cause it's very stable for me.
And peoples reports problems with the newest 6.62.

However it's already not the topic quiestion. ;)
And of course i will upgrade eventually. :)
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Jun 12, 2003 11:52 am   
 
Yes, it's good that you got it working. This proves that there is almost always more than one way of doing stuff in zMUD. Just making sure that you don't miss out on all of the great new feautures that were added since 6.16.

By the way, remember that every computer is different and just because others have problems doesn't mean you'll have the same problems. Anyway, enough about that, just make sure that you give the new version a try, remember to make all the necessary backups before upgrading, and if you have any problems come here and we'll help you out.

Kjata
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