|
cstegmann Beginner
Joined: 30 Sep 2004 Posts: 14
|
Posted: Sun Feb 20, 2005 3:32 pm
Sending exits to a var |
Hey there, i've seen a couple of posts of trigs, but i never got them to work properly.
What i'm trying to do is send all the exits to a variable as a datarecord.
the patterns look like so:
You see exits leading north and south.
You see exits leading north, up and south.
You see exits leading north (open door), up, south (closed door) and west.
Any tips on how i could do this?
Thanks |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Sun Feb 20, 2005 4:19 pm |
if all the possible exit values are known before this will work
#TRIGGER {You see exits leading (*)} {
#var exitvar ""
#fo {north|east|south|west|up|down} {
#if %regex("%1",%i) {#additem exitvar %i}
}
#echo found:@exitvar
} |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
cstegmann Beginner
Joined: 30 Sep 2004 Posts: 14
|
Posted: Sun Feb 20, 2005 4:35 pm |
Thanks, that works great.
|
|
|
|
cstegmann Beginner
Joined: 30 Sep 2004 Posts: 14
|
Posted: Mon Feb 21, 2005 8:21 pm |
Ok, just encountered a problem with that script.
trigger looks like so:
#TRIGGER {You see exits leading (*)} {
#var exitvar ""
#fo {north|northeast|east|southeast|south|southwest|west|northwest|out|in|up|down} {
#if %regex("%1",%i) {#additem exitvar %i}
}
#echo found:@exitvar
}
I get this:
A long corridor.
You see exits leading north, south, and west.
3160h, 3136m, 16024e, 16800w cexkdb@-*|22:17:33:669|*-Exits: north|south|west|out
The only place i can see "out" is in the word sOUTh, how would i stop it from doing this?
Thanks |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Mon Feb 21, 2005 8:35 pm |
no problem
#TRIGGER {You see exits leading (*)} {
#var exitvar ""
#fo {north|northeast|east|southeast|south|southwest|west|northwest|out|in|up|down} {
#if %regex("%1","\b%i\b") {#additem exitvar %i}
}
#echo found:@exitvar
}
the part in bold is the change
the \b forces the pattern to match a word boundary,so enclosing the pattern within them forces it to match a complete word
\bout\b wont match the out in south
\bsouth\b wount match the south in southwest etc |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
cstegmann Beginner
Joined: 30 Sep 2004 Posts: 14
|
Posted: Mon Feb 21, 2005 8:38 pm |
ah, perfect, thanks
|
|
|
|
aliensurfer Beginner
Joined: 11 Apr 2005 Posts: 17
|
Posted: Thu Sep 22, 2005 11:35 am |
This does work well, however there is another syntax for when there is only one exit:
You see a single exit leading <direction>
How can I add that into the trigger to pick that up? |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Thu Sep 22, 2005 12:50 pm |
#TRIGGER {You see (*) leading (*)} {
#var exitvar ""
#fo {north|northeast|east|southeast|south|southwest|west|northwest|out|in|up|down} {
#if %regex("%2","\b%i\b") {#additem exitvar %i}
}
#echo found:@exitvar
}
Try that |
|
|
|
|
|