Move execnode into a library function.
This commit is contained in:
@ -1,52 +0,0 @@
|
||||
runoncepath("lib/navigation").
|
||||
runoncepath("lib/throttle").
|
||||
|
||||
SAS off.
|
||||
local t is BurnTime(NEXTNODE:DELTAV:MAG).
|
||||
|
||||
print "Adjusting heading".
|
||||
lock STEERING to NEXTNODE:DELTAV.
|
||||
wait until VectorAngle(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).
|
||||
|
||||
// todo: pid loop here or nah? overshoot would be tricky to deal with...
|
||||
print "Executing burn.".
|
||||
|
||||
local dvMin is NEXTNODE:DELTAV:MAG.
|
||||
local throt is 1.0.
|
||||
lock THROTTLE to throt.
|
||||
|
||||
// debug
|
||||
print "dVMin = " + dvMin.
|
||||
print "dV = " + NEXTNODE:DELTAV:MAG.
|
||||
|
||||
// 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) {
|
||||
// debug
|
||||
print "dVMin = " + dvMin.
|
||||
print "dV = " + NEXTNODE:DELTAV:MAG.
|
||||
|
||||
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.".
|
||||
|
||||
// debug
|
||||
print "Final dVMin = " + dvMin.
|
||||
print "Final dV = " + NEXTNODE:DELTAV:MAG.
|
||||
|
Reference in New Issue
Block a user