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


Joined: 28 Dec 2006
Posts: 12

PostPosted: 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?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Neo2121
Beginner


Joined: 28 Dec 2006
Posts: 12

PostPosted: 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
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: 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."
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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 :(
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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