kOS/execnode.ks

37 lines
926 B
Plaintext
Raw Normal View History

runoncepath("lib/navigation").
runoncepath("lib/throttle").
2021-07-19 07:43:07 +00:00
SAS off.
local t is BurnTime(NEXTNODE:DELTAV:MAG).
2021-07-19 07:43:07 +00:00
print "Adjusting heading".
lock STEERING to NEXTNODE:DELTAV.
wait until VectorAngle(SHIP:FACING:FOREVECTOR, STEERINGMANAGER:TARGET:FOREVECTOR) <= 0.1.
2021-07-20 06:40:47 +00:00
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...
2021-07-20 06:40:47 +00:00
print "Executing burn.".
local throt is 1.0.
lock THROTTLE to throt.
local dvLast is NEXTNODE:DELTAV:MAG.
// Execute the burn, throttling down by half every time we're
// consuming more than 25% of our dV in one update.
until NEXTNODE:DELTAV:MAG <= 0.25 {
local dvRem is NEXTNODE:DELTAV:MAG.
if dvRem < dvLast * 0.75 {
set throt to throt / 2.
}
set dvLast to dvRem.
wait 0.001.
}
2021-07-19 07:43:07 +00:00
unlock THROTTLE.
unlock STEERING.
SAS on.
2021-07-20 06:40:47 +00:00
print "Node execution complete.".