Move execnode into a library function.
This commit is contained in:
39
lib/node.ks
Normal file
39
lib/node.ks
Normal file
@ -0,0 +1,39 @@
|
||||
runoncepath("lib/navigation").
|
||||
runoncepath("lib/throttle").
|
||||
|
||||
function ExecNode {
|
||||
SAS off.
|
||||
local t is BurnTime(NEXTNODE:DELTAV:MAG).
|
||||
|
||||
print "Adjusting heading".
|
||||
lock STEERING to NEXTNODE:DELTAV.
|
||||
wait until VAng(SHIP:FACING:FOREVECTOR, STEERINGMANAGER:TARGET:FOREVECTOR) <= 0.1.
|
||||
|
||||
print "Warping to node.".
|
||||
KUNIVERSE:TIMEWARP:WarpTo(NEXTNODE:TIME - (t/2) - 5).
|
||||
wait until NEXTNODE:ETA <= (t/2).
|
||||
|
||||
print "Executing burn.".
|
||||
local dvMin is NEXTNODE:DELTAV:MAG.
|
||||
lock THROTTLE to 1.0.
|
||||
|
||||
// Execute the burn, throttling down by half every time we're
|
||||
// consuming more than 25% of our dV in one update.
|
||||
local droppedOnce is false.
|
||||
until NEXTNODE:DELTAV:MAG <= 0.25 or (dVMin < NEXTNODE:DELTAV:MAG and droppedOnce) {
|
||||
|
||||
if NEXTNODE:DELTAV:MAG > dVMin {
|
||||
set droppedOnce to true.
|
||||
} else {
|
||||
set dvMin to NEXTNODE:DELTAV:MAG.
|
||||
set droppedOnce to false.
|
||||
}
|
||||
|
||||
wait 0.01.
|
||||
}
|
||||
|
||||
unlock THROTTLE.
|
||||
unlock STEERING.
|
||||
SAS on.
|
||||
print "Node execution complete.".
|
||||
}
|
Reference in New Issue
Block a user