|
Neo2121 Beginner
Joined: 28 Dec 2006 Posts: 12
|
Posted: Mon Dec 17, 2007 11:31 am
Capturing Room Exits in a String List |
typical exit line:
You see exits leading north, northeast, east, southeast, south, southwest (open door), west, and northwest.
Question:
How do I get all those directions in a string list variable? like north|west|south or whatever (not interested in the doors part, just added it so you know it can be there)
I got the part with 'north, northeast, east, southeast, south, southwest (open door), west, and northwest.' in a variable.
I just need something to detect the directions in it and add them to a string list variable.. Any thoughts? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Dec 17, 2007 12:36 pm |
#trig {^You see exits leading (*).} {#var exits %replace(%replace(%replace(%1," (open door)","")," and",""),", ","|")}
This might not work for rooms with fewer than two exits, since the trigger might not patch. |
|
|
|
Neo2121 Beginner
Joined: 28 Dec 2006 Posts: 12
|
Posted: Mon Dec 17, 2007 1:23 pm |
Code: |
#IF (%regex( @neo_exits, " north\b") != 0) {#additem neo_dir " north "}
#IF (%regex( @neo_exits, " south\b") != 0) {#additem neo_dir " south "}
#IF (%regex( @neo_exits, " east\b") != 0) {#additem neo_dir " east "}
#IF (%regex( @neo_exits, " west\b") != 0) {#additem neo_dir " west "}
#IF (%regex( @neo_exits, " northwest\b") != 0) {#additem neo_dir " northwest "}
#IF (%regex( @neo_exits, " northeast\b") != 0) {#additem neo_dir " northeast "}
#IF (%regex( @neo_exits, " southwest\b") != 0) {#additem neo_dir " southwest "}
#IF (%regex( @neo_exits, " southeast\b") != 0) {#additem neo_dir " southeast "}
|
That's how I got it to work.. It's very dirty but it does the job even for 1 exit per room... If anyone has a cleaner way to do it please share |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Tue Dec 18, 2007 1:44 am |
I don't think it's any cleaner than your's but here's another way
Code: |
#fo %subregex(%subregex(%subregex(%lower(@myvar),"(\b\w*(?:north|east|south|west)\w*)","%upper(%1)"),"(\w)","%char(%eval(%ascii(%1)+32))"),"([^a-z]+)","|") {#additem mylist %i} |
I really wish there was a way to do case sensitive regexes |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Dec 18, 2007 11:56 am |
Yeah, it's kinda pants that zMUD doesn't support the i option. You can use it in CMUD with the in-line regex syntax that's been added, but not in zMUD :(
|
|
|
|
|
|
|
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
|
|