Listing of how many routes a system hosts?

Hi, all

Trying AS3 Trial on Winchel Chung's advice. So far, it seems pretty cool (and looking at some of the deep-dish stuff others are doing with it is pretty impressive too). Question, though.

So far, I've just random generated sectors, and fiddled around with some auto ("established") routes, limited by FTL speed in my own universe and such. Seems good. Some worlds wind up with just one or two routes, and that's understandable; some I'm looking at right now have seven or eight (I set the max for 12 for this experiment).

I wanted to generate a list of the number of routes each 'routed' system has, with an eye toward making the ones with the most routes the heaviest-hitting trade centers for the sector. Unfortunately, the only data export feature that I've found so far exports all the system information except which (if any) routes it has.

Is there any way to generate such a "number of routes" list? Or should that go into the New Features Request thread?

Thanks

Davey

Comments

  • Thats not something the program can do out of the box, and honestly it's really too specific to ever be its own feature.

    There's two ways of getting the information you want:
    if you are familiar with SQL, you can use SQLite's command line tool to query the AstroDB data, since the .AstroDB files are simply SQLite database files.

    You can make a script. This is an example I made quickly that searches for all systems on more than 8 routes, and changes their label color.
    #plugin		Find Trade Centers
    #author		NBOS
    #desc		Finds and marks all systems connected to 8 or more routes
    
    sector = GetCurrentSector()
    
    'clear any previously set values
    nSystems = Sector.SystemCount()
    For i = 1 to nSystems
    	b = sector.GetSystem( i-1)
    	s = b.GetField("RouteCount")
    	If Len( s) > 0 Then
    		b.SetField "RouteCount", ""
    	End If
    Next
    
    
    'count all the bodies on the routes, incrementing a body's
    'count each time its found on a waypoint and storing that in a custom field
    nRoutes = sector.RouteCount()
    for i = 1 to nRoutes 
    	r = sector.GetRoute( i-1)
    	nWaypoints = r.WaypointCount()
    	For k = 1 to nWaypoints
    		wp = r.GetWaypoint( k -1)
    		b = wp.Body
    		
    		s = b.GetField( "RouteCount")
    		If IsNumeric( s) Then
    			c = CInt( s) + 1
    		Else
    			c = 1
    		End If 
    		
    		b.SetField "RouteCount", c
    	Next
    Next
    
    
    'change the label color of any system connected to 3 or more routes to bright purple
    'nSystems = Sector.SystemCount()
    For i = 1 to nSystems
    	b = sector.GetSystem( i-1)
    	s = b.GetField("RouteCount")
    	If IsNumeric( s) Then
    		If CInt( s) >= 8 Then
    			b.LabelColor = RGB( 255, 0, 255)
    			b.Name = UCase( b.Name)
    		End If
    	End If
    Next
    
    RefreshScene
    

    If you run this, do so against a test copy of your sector first.
  • ed_NBOS

    I do indeed know SQL; it's one of the ways I make my living. :) I'll take a look, both at your script (thanks; examples are always appreciated) and at the database itself, see what else I can figure out to query.

    Thanks!

    Davey
  • Just one comment: I'm not sure that this isn't more generally useful than people think. I know I would like the ability to export a list of trade routes by system.

Leave a Comment