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
mercatroid
Wanderer


Joined: 06 Dec 2004
Posts: 59

PostPosted: Tue Aug 22, 2006 9:58 am   

Pattern Matching
 
I'm having a pattern matching problem; wondering if anyone could help.

This is the pattern I want to match:

Quote:
[Info] =-> Player has escaped defenceless from a fight. <-=


Where "Player" is obviously a variable.

I'd like to be able to trigger off this. Specifically to assign an alias such as: #alias j {c heal Player} or {decapitate Player}, etc...

Any suggestions?

I'm using zMud 7.21

Merc
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Tue Aug 22, 2006 11:59 am   
 
Assuming that a player has only a one word name and that the output has no extra spaces and is on a line of its own.
Code:
^~[Info~] ~=~-~> (%w) has escaped defenceless from a fight. ~<~-~=$
_________________
Taz :)
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Tue Aug 22, 2006 12:24 pm   
 
since you want to have something that does both, setting a variable for people on your heal list and having #if (%1=%ismember(@heal)) {c heal %1} {decapitate %1}

I think i screwed up that #if tho. Don't have zmud with me.
_________________
http://www.Aardwolf.com
Reply with quote
mercatroid
Wanderer


Joined: 06 Dec 2004
Posts: 59

PostPosted: Thu Sep 07, 2006 9:40 pm   
 
*edit

I spoke too soon.

It doesn't pass the %w variable at all.

For example, I do:

Pattern:
Code:
^~[Info~] ~=~-~> (%w) has escaped defenceless from a fight. ~<~-~=$
Does:
Code:
dless=%w
Then make an alias for 'cap':
Code:
up;decap @dless


I tried taking out some superfluous ~ and () but to no avail.

I'm certain the problem is on my end, not with your pattern matcher.

Merc
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Sep 07, 2006 11:02 pm   
 
You need to use %1..%99 to get values for the parenthesis marked portion of the pattern. I would suggest reading the Pattern Matching page in the help.

#VAR dless {%1}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Fri Sep 08, 2006 3:17 pm   
 
Quote:
#if (%1=%ismember(@heal)) {c heal %1} {decapitate %1}

Should be: #if (%ismember(%1,@heal))
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Fri Sep 08, 2006 3:53 pm   
 
Thanks gamma, I said I was sure i'd screwed it up. :-)
_________________
http://www.Aardwolf.com
Reply with quote
mercatroid
Wanderer


Joined: 06 Dec 2004
Posts: 59

PostPosted: Fri Oct 20, 2006 10:45 pm   
 
Finally got it working:

Quote:
[Info] =-> Player has escaped defenceless from a fight. <-=


I tried the following (suggested by Taz)
Code:
^~[Info~] ~=~-~> (%w) has escaped defenceless from a fight. ~<~-~=$

Code:
dless=%w

then, to make use of it I aliased 'cap' to
Code:
up;decap @dless


Then Vijilante suggested changing %w to %1. That seems to work.

By the way, anyone reading the Pattern Matching help page in zMud would be baffled to find that %w doesn't work, as it says to use that variable for one word matching. Also, I have been flamed on these forums by other masters for having the audacity to claim that %1 usually works where %w and other variables do not.

So thanx to Taz and Vijilante!

-Merc
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Fri Oct 20, 2006 11:52 pm   
 
Quote:
By the way, anyone reading the Pattern Matching help page in zMud would be baffled to find that %w doesn't work, as it says to use that variable for one word matching. Also, I have been flamed on these forums by other masters for having the audacity to claim that %1 usually works where %w and other variables do not.



I am not sure you are understanding on when and where to use %1.
%1...%99 are used in the code section to return a captured pattern from the pattern.

working trigger
PATTERN:
Code:
^~[Info~] ~=~-~> (%w) has escaped defenceless from a fight. ~<~-~=$

VALUE:
Code:
dless=%1


%1 in the pattern is unsupported and was left in for compatibilty

Pattern Matching is a handy refrence for what to use
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
mercatroid
Wanderer


Joined: 06 Dec 2004
Posts: 59

PostPosted: Sat Oct 21, 2006 12:18 am   
 
Quote:
working trigger
PATTERN:
Code:
^~[Info~] ~=~-~> (%w) has escaped defenceless from a fight. ~<~-~=$


VALUE:
Code:
dless=%1


The above does not work. What happens is the string "%w" (as in the percentage sign and the letter W) gets passed to the variable 'dless'. Anything that then depended on the variable @dless would then send the string "%w" gets sent to the mud.

This is zMud version 7.21 btw.

Also, the pattern matching page on zMud is identical to the one in the help topics for Zmud. I have had a copy of it printed out and tacked to the wall behind my monitor for about 2 years. Nothing in it suggests your recommendation, which I guess is good since it doesn't work. Vijilante's did though, and thanks again.

-Merc
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Oct 21, 2006 5:41 am   
 
Correct (and what both Vijilante and Nexela were saying)
#trigger {This is where (%w) is used.} {WhatIsInPercentW = %1}

If this is what is not working, you need to do a complete reinstall. This sort of problem is indicative of core application corruption, not something wrong with your settings files or preferences. Any problem in this area would have to be fixed either by Zugg himself (ie, it's a bug) or be fixed by a reinstall (it's not a bug, just some messed-up data wasting space on your hard drive).

The kind of Incorrect that makes Zugg want to slap the silly out of you
#trigger {This is not where (%1) is used.} {DefinitelyDon'tDoThis = %w}

If this is what you are doing, you just aren't even trying or are not yet understanding the helpfile. %1 in this situation would, of course, work in the pattern due to the backwards compatibility Nexela referred to (as I understand it, it's old TinTin syntax), but the %w is going to be literally assigned to the variable
_________________
EDIT: I didn't like my old signature
Reply with quote
mercatroid
Wanderer


Joined: 06 Dec 2004
Posts: 59

PostPosted: Sun Oct 22, 2006 1:27 am   
 
What I am doing that works:
#trigger {This is where (%1) is being used.} {WhatIsInPercentOne = %1}

Let me repeat. It works.

When I use:
#trigger {This is where (%w) is used.} {WhatIsInPercentW = %1}

The %w is literally assigned to the variable.

MattLofton's post is the first time anyone has suggested that my zMud installation could be corrupted.

As I have done every single time anyone has helped me on these forums, I'll say thank you now.

-Merc
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