kOS/execnode.ks

36 lines
923 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)/2.
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.
print "Warping to node".
KUNIVERSE:TIMEWARP:WarpTo(NEXTNODE:TIME - t - 5).
wait until NEXTNODE:ETA <= t.
// todo: pid loop here or nah? overshoot would be tricky to deal with...
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.
print "Node Executed. Have a nice day".