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


Joined: 22 Mar 2005
Posts: 21

PostPosted: Tue May 17, 2005 11:47 am   

Restricting the list of allowed characters in a trigger
 
From zMud help file:

"To restrict the trigger to just match numbers, change the trigger to:

#TRIGGER {You get &%dGold coins}

Now the "You get many coins" will not match the trigger. You can use any of the wildcard specifiers, and can also use the square brackets [] to define your own wildcard range."


However, I can't seem to get this to work.

Edit: What I want to achieve is simply to restrict the list of allowed characters in the string to letters and space.

The string I'm receiving from the mud is something like:

Code:

You shift into the aspect of phase spider.


and the response, I want to send back is:

Code:

party say Aspect change to @Aspect complete


Combinations I've tried so far:

Code:

#TRIGGER {^You shift into the aspect of &[%w%s]Aspect.$}
#TRIGGER {^You shift into the aspect of &[a-zA-Z ]Aspect.$}
#TRIGGER {^You shift into the aspect of &[%w%s]{Aspect}.$}
#TRIGGER {^You shift into the aspect of &[a-zA-Z ]{Aspect}.$}


...but to no avail. Ideas?

.atr.
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Tue May 17, 2005 12:19 pm   
 
Should probably be;
#TRIGGER {^You shift into the aspect of (%w).$} {party say Aspect change to %1 complete}
Reply with quote
atreus
Beginner


Joined: 22 Mar 2005
Posts: 21

PostPosted: Tue May 17, 2005 12:24 pm   
 
Rorso wrote:
Should probably be;
#TRIGGER {^You shift into the aspect of (%w).$} {party say Aspect change to %1 complete}


While this would work, I can't use it, as the value has to be stored in @Aspect for statistical etc. purposes (ie. that value is referenced to in other triggers and then actions of those triggers differ based on what the value of @Aspect is - there are over 20 possible values and 4 different types of reactions).

.atr.
Reply with quote
Maelstrom
Apprentice


Joined: 10 Feb 2005
Posts: 158

PostPosted: Tue May 17, 2005 1:14 pm   
 
#TRIGGER {^You shift into the aspect of ([%w%s]).$} {
#SEND {party say Aspect change to %1 complete}
#VAR Aspect {%1}
}
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Wed May 18, 2005 2:53 am   
 
%w just matches one word

phase spider=2 words=none of the above triggers will work on it.

#TRIGGER {^You shift into the aspect of (*).$} {
#SEND {party say Aspect change to %1 complete}
#VAR Aspect {%1}
}
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
atreus
Beginner


Joined: 22 Mar 2005
Posts: 21

PostPosted: Wed May 18, 2005 6:33 am   
 
nexela wrote:
%w just matches one word


Not really. %w matches any amount of words just like [a-zA-Z] matches any amount of letters, with any amount of whitespace in between when used with %s the way Maelstrom did (which is, btw, the way I do the character-restricted string matching in many other places). In your example the problem is that it doesn't restrict the list of allowed characters (which was the whole point of this thread) in any way. Please, read what is actually being asked, before answering.

Maelstrom, thanks, that did it. Didn't think of that, st00pid me. :)

.atr.
Reply with quote
Kiasyn
Apprentice


Joined: 05 Dec 2004
Posts: 196
Location: New Zealand

PostPosted: Wed May 18, 2005 8:32 am   
 
%w match any number of alpha characters (a-z) (a word)

it matches a single word not any amount :(
_________________
Kiasyn
Owner of Legends of Drazon
Coder on Dark Legacy
Check out Talon, an easy IMC connection.
Reply with quote
atreus
Beginner


Joined: 22 Mar 2005
Posts: 21

PostPosted: Wed May 18, 2005 11:09 am   
 
Kiasyn wrote:
it matches a single word not any amount :(


No, it matches any amount of words, when used with %s like Maelstrom did. Try it yourself if you don't believe me. I've successfully used that format on a number of triggers and it works beautifully.

The bracket-enclosed list only tells which characters (or in the case of wildcards, what type of characters) are allowed and NOT how many of them there should be, unless you specifically limit that too. That's sort of the whole point of wildcards; to allow flexibility when the output is varied, don't you think?

Perhaps this is version-dependant then? At least Zugg mentioned in an earlier thread that wildcards are a rather new addition to the [] enclosed list/range of characters (see Zugg's last post in this thread).

.atr.
Reply with quote
DeReP
Adept


Joined: 14 Jun 2003
Posts: 222
Location: Chile

PostPosted: Wed May 18, 2005 2:42 pm   
 
From Zmud Helpfile
Quote:
%w match any number of alpha characters (a-z) (a word)
[range] match any amount of characters listed in range

so %w matches only one word but when its used with [range] and %s it will match words seperated with spaces.
Reply with quote
atreus
Beginner


Joined: 22 Mar 2005
Posts: 21

PostPosted: Wed May 18, 2005 9:16 pm   
 
DeReP wrote:
so %w matches only one word but when its used with [range] and %s it will match words seperated with spaces.


Any amount of words, separated by any amount of whitespace (well, at least as long as it's all on one line).

But, yes, that is exactly what I've been saying. Smile

.atr.
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