Created
January 22, 2017 19:04
-
-
Save skaven81/9e980e28958e5c53ed8883f9d9f83702 to your computer and use it in GitHub Desktop.
Broken kOS launch script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@LAZYGLOBAL OFF. | |
CLEARSCREEN. | |
// Boost phase | |
{ | |
PRINT "Phase: Pre-launch" AT (0,1). | |
LOCK THROTTLE TO 1.0. // 1.0 is the max, 0.0 is idle. | |
WHEN MAXTHRUST = 0 THEN { | |
STAGE. | |
WAIT UNTIL MAXTHRUST > 0. | |
RETURN true. | |
} | |
LOCAL MYSTEER IS HEADING(90,90). | |
LOCK STEERING TO MYSTEER. | |
LOCK angle_a TO -3 * SHIP:ALTITUDE / 1000 + 90. | |
LOCK angle_b TO -0.55 * SHIP:ALTITUDE / 1000 + 53. | |
//LOCK angle_b TO ( 1 / ((SHIP:ALTITUDE / 1000) / 500) ) - 5. | |
UNTIL SHIP:APOAPSIS > 100000 { | |
//For the initial ascent, we want our steering to be straight up and rolled due east | |
IF SHIP:ALTITUDE < 15000 { | |
// between 0 and 10,000m, use a linear progression from 90 to 45 degrees pitch | |
SET MYSTEER TO HEADING(90,angle_a). // (dir, pitch) | |
PRINT "Phase: Pitch-over A" AT (0,1). | |
PRINT "Pitch set to " + ROUND(angle_a,0) + " degrees" AT(0,15). | |
} ELSE IF SHIP:ALTITUDE > 15000 AND SHIP:ALTITUDE < 50000 { | |
SET MYSTEER TO HEADING(90,angle_b). | |
PRINT "Phase: Pitch-over B" AT (0,1). | |
PRINT "Pitch set to " + ROUND(angle_b,0) + " degrees" AT(0,15). | |
} ELSE { | |
SET MYSTEER TO SHIP:PROGRADE. | |
PRINT "Phase: Push Apoapsis" AT (0,1). | |
PRINT "Pitch set to prograde " AT(0,15). | |
} | |
PRINT "Altitude: " + ROUND(SHIP:ALTITUDE,0) + " meters" AT (0,16). | |
PRINT "Apoapsis: " + ROUND(SHIP:APOAPSIS,0) + " meters" AT (0,17). | |
WAIT 0.25. | |
} | |
} | |
CLEARSCREEN. | |
//Cruise to apoapsis | |
{ | |
PRINT "Phase: Drop booster stage". | |
//At this point, our apoapsis is above 100km. | |
//we'll make sure our throttle is zero and that we're pointed prograde | |
LOCK THROTTLE TO 0. | |
LOCK STEERING to SHIP:PROGRADE. | |
//Drop our booster stage just before we exit the atmosphere, even if | |
//it still has some fuel in it. | |
UNTIL SHIP:ALTITUDE > 65000 { | |
LOCK STEERING to SHIP:PROGRADE. | |
WAIT 1. | |
} | |
STAGE. // <-- HANGS HERE | |
PRINT "Phase: Cruise to apoapsis". | |
UNTIL ETA:APOAPSIS <= 30 { | |
LOCK STEERING to SHIP:PROGRADE. | |
WAIT 1. | |
} | |
} | |
//Circularize | |
{ | |
WHEN MAXTHRUST = 0 THEN { | |
STAGE. | |
WAIT UNTIL MAXTHRUST > 0. | |
RETURN true. | |
}. | |
PRINT "Phase: Circularize orbit". | |
LOCK THROTTLE TO 1. | |
UNTIL SHIP:PERIAPSIS >= SHIP:APOAPSIS { | |
LOCK STEERING to SHIP:PROGRADE. | |
WAIT 0.5. | |
} | |
} | |
//This sets the user's throttle setting to zero to prevent the throttle | |
//from returning to the position it was at before the script was run. | |
PRINT "Launch complete". | |
LOCK THROTTLE TO 0. | |
SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment