I am proud to present: My first ever successful orbital automatic launch system, so far, only tested with the Kerbal X rocket, but you guys are free to try it with your own.
If there are any kOS coders in here, feel free to give me some tips!!!
print "Boot success".
lock targetPitch to 88.963 - 1.03287 *alt:radar^0.39.
set targetDirection to 90.
set power to 1.
set TargetApoapsis to 85000.
set targetPeriapsis to 70000.
from {local countdown is 3.} until countdown = 0 STEP {set countdown to countdown -1.} do {
print (countdown).
wait 1.
}
print "launch".
lock throttle to power.
stage.
lock steering to up.
wait 5.
print "steering nominal...".
set oldThrust to ship:AVAILABLETHRUST.
when AVAILABLETHRUST < (oldThrust) then {
stage.
print "stage success".
lock throttle to power.
wait 1.
set oldThrust to ship:AVAILABLETHRUST.
preserve.
}
wait until ship:altitude > 50.
lock steering to heading(targetDirection, targetPitch).
wait until ship:altitude >= 18500.
lock throttle to 0.5.
function Shutd0wn1{
wait until ship:apoapsis >= TargetApoapsis.
set power to 0.
lock throttle to power.
}
Shutd0wn1().
lock steering to prograde.
wait until ship:altitude >= 84500.
lock throttle to 1.
wait until TargetPeriapsis <= ship:periapsis.
lock throttle to 0.
wait 1.
print "Capsule is in orbit".
wait 10.
stage.
wait 5.
toggle AG1.```
Note that there is no way to get back to the earth after reaching orbit with this script, i have not made a return system... YET