Skip to content

Instantly share code, notes, and snippets.

@enyachoke
Forked from MetroWind/Launch
Created June 1, 2018 15:00
Show Gist options
  • Save enyachoke/2c3c7b003467057ab2cb0de1a2384425 to your computer and use it in GitHub Desktop.
Save enyachoke/2c3c7b003467057ab2cb0de1a2384425 to your computer and use it in GitHub Desktop.
KSP kOS launch script
CLEARSCREEN.
//This is our countdown loop, which cycles from 10 to 0
PRINT "Counting down:".
FROM {local countdown is 10.} UNTIL countdown = 0 STEP {SET countdown to countdown - 1.} DO
{
PRINT "..." + countdown.
WAIT 1. // pauses the script here for 1 second.
}
WHEN MAXTHRUST = 0 THEN
{
PRINT "Staging".
wait 0.5.
STAGE.
PRESERVE.
}.
// Path controll
SET MYSTEER TO HEADING(90,90).
LOCK STEERING TO MYSTEER.
wait until ship:velocity:surface:mag > 100.
print "Steering to 80...".
set MYSTEER to heading(90, 80).
wait until ship:velocity:surface:mag > 200.
print "Steering to 70...".
set MYSTEER to heading(90, 70).
wait until ship:velocity:surface:mag > 300.
print "Steering to 60...".
set MYSTEER to heading(90, 60).
wait until ship:velocity:surface:mag > 400.
print "Steering to 50...".
set MYSTEER to heading(90, 50).
wait until ship:velocity:surface:mag > 500.
print "Steering to 45...".
set MYSTEER to heading(90, 45).
wait until APOAPSIS > 80000.
print "Apoapsis at 80km. Cutting throttle...".
LOCK THROTTLE TO 0.0.
wait 1.
UNLOCK STEERING.
sas on.
// For some reason have to wait a bit here.
wait 0.5.
SET SASMODE TO "PROGRADE".
// Now we wait for the ship to be near the apoapsis and start burning.
wait until ship:altitude > 78500.
print "Burning to circulate...".
lock throttle to 1.0.
// Wait for the orbit to be round. There's no way the orbit can be a perfect circle, so we just wait for the eccentricity to reach minimum.
declare epre to ship:orbit:ECCENTRICITY.
until ship:orbit:ECCENTRICITY > epre
{
set epre to ship:orbit:ECCENTRICITY.
wait 0.1.
}
LOCK THROTTLE TO 0.0.
set SHIP:CONTROL:PILOTMAINTHROTTLE to 0.0.
wait 1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment