Creating routes according to stellar mass

What I'm trying to create is a script that will go through stars in the sector and do the following:

If the combined stellar mass of two stars is over a given level (call it X), the stars are connected by a route if they are closer than Y light years apart, where Y is calculated from X.

So, for instance, if Y = X*6, and you have two stars of 1 solar mass each, X = 2 and Y = 12. So if the stars are within 12 light years of each other, they are connected by a route.

I've been able to figure out a script that takes two selected stars and tells me via text box if they are connected or not. What I have not been able to figure out is how to connect those two stars (assuming they are within the right distance) by a route that shows up on the screen. If I knew how to get the script to draw a route between two selected stars, it should be reasonably simple to modify the script to cycle through the stars. I just can't figure out how to create that simple route.

Comments

  • I can't help you, but I'd be really interested in seeing your scripts! (the FTL in one of my SF backgrounds works in a simliar mass-determined way)
  • Well, right now I'd just be happy with knowing how to connect to stars with a route via a script. The lack of documentation is...distressing.
  • KeithM wrote:
    Well, right now I'd just be happy with knowing how to connect to stars with a route via a script. The lack of documentation is...distressing.

    Yeah, it kinda pisses me off actually. I don't really see the point of having an API if the author isn't going to bother to explain what half of the fuctions/properties are or how to use them. It's not as if there's much of a community on these boards that can help eachother out either.
  • I would love to see a script like that as well. My FTL travel is roughly based on the Alderson Drive from Jerry Pournelle's novels.
  • I can't upload to the site, so you'll have to copy and paste from here. This is the very crude first version. In order to change the formula used to calculate whether stars are connected or not, you have change it in the code. For this one all I did was to take the total mass of the two star systems and multiply it by three to get the max connection distance in light years. If it's taking too long, hitting the ESC key will end the script.
    #plugin  Automatic Hyperspace Jump Plotter
    #author	Keith Morrison
    #desc	Calculates Hyperspace Links Based on a given formula
    
    # version 1.0
    
    sector = GetCurrentSector()
    Count = sector.SystemCount()
    
    # Appearance of Hyperlink
    
    Hyper = CreateRoute()
    Hyper.Name = ""
    Hyper.RouteType = ""
    Hyper.Red = 0.6
    Hyper.Blue = 1
    Hyper.Green = 0.6
    Hyper.LineWidth = 1
    Hyper.Linestyle = 0
    
    # Loop through all systems
    
    For i = 1 to Count
    
    	sys1 = sector.GetSystem( i-1)
    
    # Loop through all other systems
    
    	For j = i to Count - 1
    	
    		sys2 = sector.GetSystem( j)
    
    # Calculate distance beween systems
    	
    		dx = sys2.x - sys1.x
    		dy = sys2.y - sys1.y
    		dz = sys2.z - sys1.z
    	
    		dist = Sqr( (dx*dx) + (dy*dy) + (dz*dz))
    		
    # Calculate combined solar mass of systems: if a system is multiple star system, component masses are added together.
    	
    		if sys1.TypeID = BODY_TYPE_MULT then
    			childnum = sys1.ChildrenCount
    			mass1 = 0
    			for c = 1 to childnum
    				o = sys1.GetChild ( c-1)
    				mass1 = mass1 + o.Mass
    			next
    		else
    			mass1 = sys1.Mass
    		end if
    	
    		if sys2.TypeID = BODY_TYPE_MULT then
    			childnum = sys2.ChildrenCount
    			mass2 = 0
    			for c = 1 to childnum
    				o = sys2.GetChild ( c-1)
    				mass2 = mass2 + o.Mass
    			next	
    		else
    			mass2 = sys2.Mass
    		end if
    
    # Calculate the total mass of the two star systems
    	
    		mtotal = mass1 + mass2
    
    # Equation to determine whether systems are connected or not
    	
    		jdist = mtotal*3
    
    # Route creation		
    		
    		if dist < jdist then
    			wp1 = CreateWaypoint()
    			wp1.body = sys1
    			wp1.ID = sys1.IDString
    			wp1.x = sys1.x
    			wp1.y = sys1.y
    			wp1.z = sys1.z
    			Hyper.AddWaypoint wp1
    			wp2 = CreateWaypoint()
    			wp2.body = sys2
    			wp2.ID = sys2.IDString
    			wp2.x = sys2.x
    			wp2.y = sys2.y
    			wp2.z = sys2.z
    			Hyper.AddWaypoint wp2
    			Sector.AddRoute Hyper
    			RefreshScene()			
    		end if
    
    		k = GetKey()
    		if k = 27 then
    			j = Count - 1
    			i = Count
    		End if		
    
    	Next
    	
    Next
    
    MsgBox "Completed"
    

Leave a Comment