|
atreus Beginner
Joined: 22 Mar 2005 Posts: 21
|
Posted: 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. |
|
|
|
Rorso Wizard
Joined: 14 Oct 2000 Posts: 1368
|
Posted: 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} |
|
|
|
atreus Beginner
Joined: 22 Mar 2005 Posts: 21
|
Posted: 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. |
|
|
|
Maelstrom Apprentice
Joined: 10 Feb 2005 Posts: 158
|
Posted: 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}
} |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: 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}
} |
|
|
|
atreus Beginner
Joined: 22 Mar 2005 Posts: 21
|
Posted: 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. |
|
|
|
Kiasyn Apprentice
Joined: 05 Dec 2004 Posts: 196 Location: New Zealand
|
Posted: 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 :( |
|
|
|
atreus Beginner
Joined: 22 Mar 2005 Posts: 21
|
Posted: 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. |
|
|
|
DeReP Adept
Joined: 14 Jun 2003 Posts: 222 Location: Chile
|
Posted: 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. |
|
|
|
atreus Beginner
Joined: 22 Mar 2005 Posts: 21
|
Posted: 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.
.atr. |
|
|
|
|
|