|
Podar Newbie
Joined: 17 Aug 2002 Posts: 7 Location: USA
|
Posted: Fri Sep 20, 2002 6:31 pm
Autoconnecting rooms |
In the mud that I play on there are several grid zones with exactly matching rooms that are just perfect squares. Is there a way that I can map the zone and interconnect the rooms with out having to hit each and every exit of each room or go into the properties of each room and manually connect them?
Using Zmud 6.16, btw and love the mapper except for this one little problem I've run into.
Thanks,
Podar |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sat Sep 21, 2002 6:50 pm |
I suppose you could do this using the "spreadsheet editing mode". I doubt it would be any easier or any less time-consuming, it would more likely be the opposite.
LightBulb
Senior Member |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Sep 22, 2002 3:26 am |
Since a few people asked about this recently I thought I would whip up a script to handle it. So here it is:
#CLASS {AutoLink}
#ALIAS SetRange {#IF (%roomnum(%1)=%null) {#ECHO Must specify a valid start room.} { #IF (%roomnum(%2)=%null) {#ECHO Must specify a valid end room.} {RangeData="";#IF (%1<%2) {#ADDKEY RangeData Low %1;#ADDKEY RangeData High %2} {#ADDKEY RangeData Low %2;#ADDKEY RangeData High %1};RoomChecking="";#LOOP %db(@RangeData,Low),%db(@RangeData,High) {#IF (%roomnum(%i)!=%null) {#ADDKEY RangeData %i %roomexit(%i);#ADDITEM RoomChecking %i}}}}}
#ALIAS CalculateSpatial {#IF (%null(@RangeData)) {#ECHO RangeData not set please use SetRange first.} {Xpos=0;Ypos=0;Zpos=0;Spatial="";#ADDKEY Spatial %concat(@Xpos,"|",@Ypos,"|",@Zpos) %item(@RoomChecking,1);#WHILE (@RoomChecking) {RoomPos=0;#LOOPDB @Spatial { #IF (%val=%item(@RoomChecking,1)) {RoomPos=1;Xpos=%item(%key,1);Ypos=%item(%key,2);Zpos=%item(%key,3)}};#IF (@RoomPos) {#FORALL %db(@RangeData,%item(@RoomChecking,1)) { #IF (%db(@RangeData,%roomlink(%item(@RoomChecking,1),%i))!=%null) { #ADDKEY Spatial @Relative(%i) %roomlink(%item(@RoomChecking,1),%i)}};#DELNITEM RoomChecking 1} {RoomPos=%item(@RoomChecking,1);#DELNITEM RoomChecking 1;#ADDITEM RoomChecking @RoomPos}}}}
#ALIAS FixLinks {#IF (@Spatial=%null) {#ECHO Must run CalculateSpacial first.} {#LOOPDB @Spatial {Xpos=%item(%key,1);Ypos=%item(%key,2);Zpos=%item(%key,3);RoomPos=%val;#FORALL %db(@RangeData,%val) { #IF (%roomlink(@RoomPos,%i)=-2) { #IF (%db(@Spatial,@Relative(%i))!=%null) {#NOOP %roomlink(@RoomPos,%i,%db(@Spatial,@Relative(%i)))}}}};RangeData="";Spatial=""}}
#VAR RangeData {} {}
#VAR Spatial {} {}
#VAR Zpos {0} {0}
#VAR Ypos {0} {0}
#VAR Xpos {0} {0}
#VAR RoomChecking {} {}
#VAR RoomPos {0} {0}
#VAR Relative {%if(%1=n,%concat(@Xpos,"|",%eval(@Ypos-1),"|",@Zpos),%if(%1=s,%concat(@Xpos,"|",%eval(@Ypos+1),"|",@Zpos),%if(%1=w,%concat(%eval(@Xpos-1),"|",@Ypos,"|",@Zpos),%if(%1=e,%concat(%eval(@Xpos+1),"|",@Ypos,"|",@Zpos),%if(%1=nw,%concat(%eval(@Xpos-1),"|",%eval(@Ypos-1),"|",@Zpos),%if(%1=sw,%concat(%eval(@Xpos-1),"|",%eval(@Ypos+1),"|",@Zpos),%if(%1=ne,%concat(%eval(@Xpos+1),"|",%eval(@Ypos-1),"|",@Zpos),%if(%1=se,%concat(%eval(@Xpos+1),"|",%eval(@Ypos+1),"|",@Zpos),%if(%1=u,%concat(@Xpos,"|",@Ypos,"|",%eval(@Zpos-1)),%if(%1=d,%concat(@Xpos,"|",@Ypos,"|",%eval(@Zpos+1)),%null))))))))))}
#CLASS 0
I left it as 3 seperate aliases because each one could take some time to run (note the large number of loops involved). This allows you to control how intensively it goes. To start you have to find the high and low room number for the section you want to connect up, use that as arguments for SetRange. Then CalculateSpatial, and finally FixLinks.
Enjoy, also being posted to finished scripts forum. |
|
|
|
|
|
|
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
|
|