|
SBG Novice
Joined: 05 Mar 2003 Posts: 44 Location: Australia
|
Posted: Tue Apr 07, 2015 12:49 pm
Deleting Empty Room Links |
Hi,
so basically I have paths plotted through the wilds and all paths end up with null links poking out all over the place
so I wanted to remove those just to make the map look a bit more tidy and doing it by hand one at a time is out of the question,
after a week of going over the guide/s I ended up with this as a alias:
Code: |
#IF (%roomlink( , n , )= -2) {#CALL %roomlink( , n , -1)}
#IF (%roomlink( , s , )= -2) {#CALL %roomlink( , s , -1)}
#IF (%roomlink( , e , )= -2) {#CALL %roomlink( , e , -1)}
#IF (%roomlink( , w , )= -2) {#CALL %roomlink( , w , -1)}
#IF (%roomlink( , up , )= -2) {#CALL %roomlink( , up , -1)}
#IF (%roomlink( , down , )= -2) {#CALL %roomlink( , down , -1)}
#IF (%roomlink( , ne , )= -2) {#CALL %roomlink( , ne , -1)}
#IF (%roomlink( , nw , )= -2) {#CALL %roomlink( , nw , -1)}
#IF (%roomlink( , se , )= -2) {#CALL %roomlink( , se , -1)}
#IF (%roomlink( , sw , )= -2) {#CALL %roomlink( , sw , -1)}
|
and it seems to work, but I get the feeling it could be better, but I'm at a loss as to how.
If anyone can make this work better and not so kluncky, please feel free to add suggestions.
Many Thanks, Mark |
|
_________________ Windows 7U x64 SP1
AMD Phenom X4 9650
8 Gig mem
CMUD Pro v3.34
Zmapper v1.30 |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Wed Apr 08, 2015 9:51 am |
Code: |
#FORALL {n|s|e|w|up|down|ne|nw|se|sw} {#IF (%roomlink(, %i) = -2) {#CALL %roomlink(, %i, -1)}} |
|
|
|
|
apfinger Novice
Joined: 19 Nov 2006 Posts: 40
|
Posted: Wed Apr 08, 2015 7:19 pm |
Checking all 10 directions every single time seems a bit overkill. I haven't touched automappers, so maybe it is necessary. The loop certainly shortens 10 lines to 1 - can %roomexit() replace n|s|e|w|up|down|ne|nw|se|sw ? Doc says it returns a stringlist of exits for the current room, which is likely less than 10 in every single room.
Code: |
#FORALL {%roomexit()} {#IF (%roomlink(, %i) = -2) {#CALL %roomlink(, %i, -1)}} |
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Wed Apr 08, 2015 10:31 pm |
The only problem with using %roomexit like that is that is uses h, j, k, and l for nw, ne, sw, and se. It is not too hard to overcome. Here is an alias to do an entire zone at once.
Code: |
#ALIAS cleanzone {
$z=%zonenum(%1)
#IF ($z==-1) {
#SHOW {Invalid zone name. Valid names are:}
#LOOP %numzones {#ECHO %zonename(%zonevnum(%i))}
#EXIT
}
$z=%zonevnum($z)
$dirs="n=n|e=e|s=s|w=w|u=u|d=d|h=nw|j=ne|k=sw|l=se"
$roommode=%roommode()
#CALL %roommode(1)
$rooms=%mapquery(%concat("ZoneID=",$z))
#FORALL $rooms {
#FORALL %roomexit(%i) {
$d=%db($dirs,%j)
#IF (%roomlink(%i, $d)==-2) {#CALL %roomlink(%i,$d,-1)}
}
}
#CALL %roommode($roommode)
} |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
SBG Novice
Joined: 05 Mar 2003 Posts: 44 Location: Australia
|
Posted: Wed Apr 08, 2015 11:13 pm |
Thanks Guys, this information will go a long way in helping me understand the automapper better, and cmud commands in general.
I knew there had to be a cleaner way to do this, so I really appreciate your input!
Mark. |
|
_________________ Windows 7U x64 SP1
AMD Phenom X4 9650
8 Gig mem
CMUD Pro v3.34
Zmapper v1.30 |
|
|
|
|
|
|
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
|
|