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
xekon
Apprentice


Joined: 11 Oct 2007
Posts: 154

PostPosted: 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!"
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
xekon
Apprentice


Joined: 11 Oct 2007
Posts: 154

PostPosted: 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.
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