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


Joined: 11 Jul 2006
Posts: 13

PostPosted: Tue Feb 20, 2007 2:50 am   

Moving to every room in a zone
 
is there a function or a script that could be used to tell the mapper to move you to each room in the zone? I want to move to every room in the zone, let's say looking for things, or checking to make sure something isn't there. Is it possible?
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Wed Feb 21, 2007 1:41 pm   
 
Whilst I'm visiting these forums again, I'll help you out. What you're looking for is %mapfilter.

Direct from the help file:
#CALL %mapfilter(%concat("ZoneID = ",%zonenum()))
#LOOP %numrooms {#SHOW %roomname(%mapvnum(%i))}
#CALL %mapfilter("")

This will loop between the rooms in the zone and output their names. What you're looking for, would be something like this:

#alias OutputRooms {#CALL %mapfilter(%concat("ZoneID = ",%zonenum(%1)))
#LOOP %numrooms {#additem ZoneRooms %mapvnum(%i)}
#CALL %mapfilter("")}
#alias WalktoRoom {#walk %item(@OutputRooms,1)
#delnitem OutputRooms 1}

To use, you start by using the first alias, and parse to it the zone number you want to search. Then you use the second alias to walk to each room in the list. Alternatively, you can remove "%1" from the first alias to search the current zone you are in. I also use an alias to walk to the closest room first, then to the next closest room etc. This should hopefully minimise the distance I have to travel. I've included this alias below, in case you want to do something similar. It stores the vnum of the closest room in the DB variable record @NearestRoom.RoomVnum

#alias NearestRoom {NearestRoom.PathLength=2000
NearestRoom.RoomVnum=%null
#loop 1,%numitems(%-1) {#if (%numitems(%pathexpand(%walk(%item(%-1,%i))))<@NearestRoom.PathLength) {#addkey NearestRoom RoomVnum %item(%-1,%i)
#addkey NearestRoom PathLength %numitems(%pathexpand(%walk(%item(%-1,%i))))} {}}}
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