 |
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Wed Apr 04, 2007 4:13 am
help with room exits |
When I check the exits in a room I could get the following:
Dawn has lit the sky with her streamers of rosy red. You notice exits north, northeast, east, southeast, south, southwest, west, northwest, and down (a closed door).
How could I get each exit into a varible?
exit1 = north
exit2 = northeast
ect.
The exit part of the room description could possibly be on two lines too. |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Apr 04, 2007 10:17 am |
There's probably a more convenient way to do this depending on what exactly you want to do with it. If you use the automapper, for example, then %roomexit() will contain a string list of the exits of the current room.
|
|
|
|
 |
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Wed Apr 04, 2007 2:19 pm |
I haven't tried to use the automapper in years. It use to slow everything down.
All I really want is to be able to make a quick escape ailias. One where I could just hit a button and zmud would just pick one of the availiable directions for me.
It is hard to keep up with which way is up when your moving around a lot.
Any help with my idea or alternate ideas would be welcome here. |
|
|
|
 |
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Tue Apr 10, 2007 2:04 am |
any ideas? other than with the automapper.
|
|
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Apr 10, 2007 3:31 am |
If you don't want to use the mapper, set up a trigger to match the exits line. This trigger will parse the exits information for commas and " and ", replacing all of that with | in the appropriate spots. From there, the stringlist can be used and checked by whatever initiates your escape routines:
#trigger {*You notice exits (*).} {#if (%pos(", ","%1")) {#noop the list has commas;RoomExits = %replace("%1"," and "," ")} {#noop the list does not have commas;RoomExits = %replace("%1"," and ",", ")};RoomExits = %replace(@RoomExits,", ","|")}
#alias RunAway {EscapeDir = %item(@RoomExits,%random(1,%numitems(@RoomExits)));#if (%pos("(a closed door)",@EscapeDir)) {#noop oh no! this way blocked;RunAway} {#noop sweet freedom, you are mine!;@EscapeDir}}
Be forewarned, the alias might get stuck, but what it's supposed to do is call itself and choose again if the chosen exit contains messaging for a closed door. |
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Tue Apr 10, 2007 10:26 pm |
That works really well for what I need. Thanks a lot Matt. As usual I missed one possibility that pops up quite often. I'm afraid to touch this code ( I'll probably screw it up), if you could take a look and let me know what to do in this case.
You notice a single exit, west. |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Apr 10, 2007 10:58 pm |
Probably be best to create a separate trigger for that, since it's always going to be quite a simple pattern.
#trig {You notice a single exit, (%w).} {RoomExits=%1} |
|
|
|
 |
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Wed Apr 11, 2007 5:38 am |
Duh! Of course. That works. Thanks
|
|
|
|
 |
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Fri Apr 13, 2007 12:28 am |
One last thing. Now the room exits trigger works great, but like MattLofton said the ailias might not work. Its worse than that. It makes my zmud disappear. No see ya later error message, just poof.
If there were a way to just exclute closed door exits from the list the ailias shouldn't have any real problems right? Just have a message pop up in the case of all closed doors that says your'e trapped.
Anyhow, I've been messing around with %ismember and #delitem, but my zmud skills just are not up to the job. MattLofton or somebody help me update this trigger to exclude closed doors please. |
|
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Fri Apr 13, 2007 1:48 am |
| Quote: |
#alias RunAway {EscapeDir = %item(@RoomExits,%random(1,%numitems(@RoomExits)));#if (%pos("(a closed door)",@EscapeDir)) {#noop oh no! this way blocked;RunAway} {#noop sweet freedom, you are mine!;@EscapeDir}}
|
I didn't think it was going to be that spectacular. Was just figuring on extra attempts or picking closed doors and stuff like that.
Anywho, onwards to the work.
| Quote: |
#trigger {*You notice exits (*).} {#if (%pos(", ","%1")) {#noop the list has commas;#forall %replace(%replace("%1"," and "," "),", ","|") {#if (!%pos("(closed door)",%i)) {#additem RoomExits %i}}} {#noop the list does not have commas;#forall %replace("%1"," and ","|") {#if (!%pos("(closed door)",%i)) {#additem RoomExits %i}}}}
|
I don't particularly like Zmud's attempt at temporary variables, nor modifying whatever variable I'm using as the loop iteration condition, so I moreorless just doubled the code to account for the two situations. What it should be doing is listifying the %1 wildcard data and then only adding the open directions to the @RoomExits variable. Simple enough, right?
| Quote: |
#alias RunAway {#if (%numitems(@RoomExits)) {%item(@RoomExits,%random(1,%numitems(@RoomExits)))} {#noop oh, puppy nuggets! trapped like a vicious beagle mother defending her puppies!;#SAY "!!!!!!!!!!!!!!!!!!!!!!!DANGER, (insert your name here), FLIGHT IS IMPOSSIBLE!!!!!!!!!!!!!!!!!!!!!!!}}
|
The lack of closed doors made the alias a lot simpler, so now it only checks whether there ARE exits and if so picks a random one. |
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Thu Apr 19, 2007 10:16 pm |
I hate to keep beating the dead horse, but this is almost a great bit of programming for me.
The only problem is that the room exit with the close door isnt actually removed from the list or roomexits.
The (closed door) part is removed, but the ailias still tries to go in the direction of the closed door.
Its not causeing my zmud to crash now so it is a major improvement, however if there is a way to remove the direction from the list entirely that would be best.
whats the deal with the comments after the #noop statement?  |
|
|
|
 |
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Thu Apr 19, 2007 11:57 pm |
Im trying to check the roomexits list one at a time and if it contains any closed doors remove them. this is my attempt at zmudding:
#IF (%pos( "a closed door", (%item( @roomexits, 1)))) {#delitem roomexits (%item( @roomexits, 1)}
#IF (%pos( "a closed door", (%item( @roomexits, 2)))) {#delitem roomexits (%item( @roomexits, 2)}
ect.
the first part of the if statement seems to work ok, i just cant seem to find the proper commad structure to remove the offending item.
if someone can fix this or has a plan to make it work off of the trigger in the beginning or another idea please dont be shy.
someone please make it go away. |
|
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Fri Apr 20, 2007 12:02 am |
Oh, hmm. %pos() must be getting confused by the %i part. Changing it to "%i" should fix the issue.
| Quote: |
whats the deal with the comments after the #noop statement?
|
That's just my style. When my eyes glaze over from the massed elegance of ZMud-formatted scripts, such funny and entertaining notes really stand out better than serious, explanatory ones. Plus, the code wasn't actually tested before posting, so I wanted something to stand out indicating the sections. |
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Fri Apr 20, 2007 2:36 am |
That didnt seem to make a difference.
|
|
|
|
 |
Leitia Adept

Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Sat May 05, 2007 4:03 pm a closed door = 1 |
When I processed the exits I ran into problems. I was not sure how the code handled the parenthesis in the formula so I removed them in the stringlist replacing (closed door) with J. Then where any direction had a j in it I added it to its own list. I am not really efficient, and am not sure how to tell the code ( ) is just text, must be ~ or something, anyway, you may be running into that issue.
|
|
|
|
 |
Leitia Adept

Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Sat May 05, 2007 5:27 pm aside |
Oh the thought occured to me that you may need to remove each side of the parenthesis to please the syntax checker. I do not think it is needed though. I did each side separately at the time for that reason.
|
|
|
|
 |
|
|
|