 |
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Sun Mar 16, 2008 2:32 pm
Dynamic Area Entrance Index Creator, Captures vnum of closest room in each zone |
Dynamic Area Entrance Index Creator, Captures vnum of closest room in each zone.
This vnum is useful information for creating additional triggers that walk to the entrance of a zone.
With a script like this when maps change you might need to update your indexes.
Also with a script like this it should work with anyones map and on any mud.
The script appears to work for most zones however every once in a while it uses -1 instead of issueing a vnum, also sometimes it picks a room that is NOT the closest from my position. So if anyone can finish this script off to do what i intended for it to do, then please post back with the fix.
Code: |
$closeroomvnum=""
#loop %numzones {
$thezoneid=%zonevnum(%i)
#call %mapfilter(%concat(ZoneID='$thezoneid'))
#win 1 "ZoneID:"$thezoneid" Rooms:"%numrooms( )
$rundistance=9000
#loop 1,%numrooms( ) {
TotalCost=0
CurRoom=%roomnum()
#forall %pathexpand(%pathfrom(,%mapvnum( %i))) {
NextRoom=%roomlink(@CurRoom,%i)
#add TotalCost %roomcost(@NextRoom)
CurRoom=@NextRoom
}
#IF ($rundistance>@TotalCost) {
$closeroomvnum=%mapvnum( %i)
$rundistance=@TotalCost
} {}
}
#VA %replace(%zonename($thezoneid,name)," ","") $closeroomvnum $closeroomvnum arealinks|thezones
#call %mapfilter("")
}
#SHOW "ALL DONE!"
|
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Mar 16, 2008 5:54 pm |
Why are you setting a default value for the variable at the end? Also, why are you using global variables for some of the script and local variables for the rest? You posted this to the zMUD section - is this a zMUD script or a CMUD script? Also, seems to me like a data record variable would be the perfect way to store the final values.
|
|
|
 |
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Mon Mar 17, 2008 12:22 am |
I set the default value because I was not sure how else to set the folders these were created in, without having the default value stored as well.
Some variables are global and others where local so that i could debug easier, once i was finished nearly all would be local variables.
I wrote this script for cmud. and yes once i had it working better I could change it to use a data record... was just trying to get it to work CORRECTLY first.
To clear things up, this script ALMOST works correctly, but not quite, sometimes it chooses the wrong room for reasons unknown to me also, sometimes it does not choose a room at all and just stores a values of -1 instead of a room vnum for some zones. |
|
|
 |
|
|
|
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
|
|