// Inital gravity turn run once staging. run once maneuver. function doAscentSteering { parameter heading. // initial pitch-over set tarSteer to heading(heading, 90). lock steering to tarSteer. until ship:velocity:surface:mag >= 100 { set tarSteer to heading(heading, 90 - (ship:velocity:surface:mag / 10)). wait 0. } lock steering to ship:srfprograde. print "Locked steering to surface prograde". } function createCircularizationNode { // Re-use existing node if already planned if hasnode { print "Existing node found. Skipping creation.". return nextnode. } local rBurn to body:radius + apoapsis. local vTarget to sqrt(body:mu / rBurn). local dvEst to vTarget - ship:velocity:orbit:mag. local nd to node(time:seconds + eta:apoapsis, 0, 0, dvEst). add nd. return nd. } function basicAscent { parameter heading is 90, targetAltitude is 80000. lock throttle to 1. print "Counting down:". from {local countdown is 5.} until countdown = 0 step {set countdown to countdown - 1.} do { print "..." + countdown. wait 1. } // initial stage to takeoff stage. // stage everytime thrust drops to zero basicStaging(). // basic gravity-ish turn doAscentSteering(heading). // coast to apoapsis wait until ship:apoapsis >= targetAltitude. lock steering to ship:prograde. lock throttle to 0. // don't do futher calcs until out of the atmosphere or very close to apoapsis wait until ship:altitude >= body:atm:height or eta:apoapsis < 60. executeNode(createCircularizationNode()). print "Circularized". }