Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Falcon 9 (Cargo) script
- SAS off.
- RCS off.
- lights off.
- lock throttle to 0.
- gear off.
- clearscreen.
- set targetapoapsis to 190000.
- set targetperiapsis to 190000.
- set runmode to 2.
- if ALT:RADAR < 103 {
- set runmode to 1.
- }
- until runmode = 0 {
- if runmode = 1 {
- lock steering to UP.
- set TVAL to 1.
- stage.
- set runmode to 2.
- }
- else if runmode = 2 {
- lock steering to heading (90,90).
- set TVAL to 0.7.
- if SHIP:ALTITUDE > 1000 {
- set runmode to 3.
- }
- }
- else if runmode = 3 {
- set targetPitch to max( 5, 90 * (1 - ALT:RADAR / 100000)).
- lock steering to heading ( 90, targetPitch).
- set TVAL to 0.7.
- if SHIP:GROUNDSPEED > 450 {
- stage.
- rcs on.
- set TVAL to 0.
- set runmode to 4.
- }
- }
- else if runmode = 4 {
- lock steering to heading ( 270, 0).
- if VERTICALSPEED < 1 {
- ag1 on.
- set TVAL to 1.
- if (SHIP:GROUNDSPEED > 500) and (SHIP:VERTICALSPEED < -100) {
- set TVAL to 0.
- set runmode to 5.
- }
- }
- }
- else if runmode = 5 {
- lock steering to srfretrograde.
- if ship:altitude < 50000 {
- set runmode to 0.
- }
- }
- lock throttle to TVAL.
- print "RUNMODE: " + runmode + " " at (5,4).
- print "ALTITUDE: " + round(SHIP:ALTITUDE) + " " at (5,5).
- print "APOAPSIS: " + round(SHIP:APOAPSIS) + " " at (5,6).
- print "PERIAPSIS: " + round(SHIP:PERIAPSIS) + " " at (5,7).
- print "ETA to AP: " + round(ETA:APOAPSIS) + " " at (5,8).
- }
- run gravity_calculator.
- run suicide_burn_calculator.
- clearscreen.
- wait 1.
- sas on.
- set vLand to -4.
- set runmode to 7.
- set thrust to ship:maxthrust.
- set counter to 0.
- lock h to alt:radar.
- lock vd to ship:verticalspeed.
- lock vDiff to (vLand - vd).
- lock TimeToBurn to ((suicide_burn_calculator(1.05)-h)/vd).
- lock ZeroAccelThrust to ((Ship:mass*g)/thrust).
- until runmode = 6 {
- set g to -gravity_calculator().
- if runmode = 7 {
- set TVAL to 0.
- if h > 5000 {
- lock steering to retrograde.
- }
- if h < 50000 {
- ag3 on.
- lock steering to srfretrograde.
- set runmode to 8.
- }
- }
- if runmode = 8 {
- if h < (suicide_burn_calculator(1.05) - vd) {
- set TVAL to 1.
- RCS on.
- }
- else {
- set TVAL to 0.
- }
- if h/-vd < 2 {
- brakes off.
- }
- if alt:radar < 400 {
- gear on.
- }
- if vd > -6 {
- lock steering to up.
- set runmode to 9.
- }
- }
- if runmode = 9 {
- if vDiff > 0 {
- set TVAL to (ZeroAccelThrust + 0.1).
- }
- if vDiff < 0 {
- set TVAL to (ZeroAccelThrust - 0.1).
- }
- if vd > -0.1 and h < 100 {
- set counter to counter + 1.
- wait 0.1.
- }
- if counter > 20 {
- set runmode to 6.
- }
- }
- lock throttle to TVAL.
- print "Vertical Velocity: " + round(vd, 2) + " " at (5,4).
- print "Required Burn Height: " + round(suicide_burn_calculator(1.1), 2) + " " at (5,5).
- print "Time to Required Burn " + round(TimeToBurn, 2) + " " at (5,6).
- print "Runmode: " + runmode + " " at (5,7).
- print "Gravitational Acceleration: " + round(g, 2) + " " at (5,8).
- }
- if runmode = 6 {
- set TVAL to 0.
- unlock throttle.
- clearscreen.
- print "Landing Complete" at (5,4).
- wait 1.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement