Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Falcon 9 (Cargo) script
  2.  
  3. SAS off.
  4. RCS off.
  5. lights off.
  6. lock throttle to 0.
  7. gear off.
  8.  
  9. clearscreen.
  10.  
  11. set targetapoapsis to 190000.      
  12. set targetperiapsis to 190000.     
  13.  
  14. set runmode to 2.
  15. if ALT:RADAR < 103 {
  16.     set runmode to 1.
  17.     }
  18.    
  19.  
  20.    
  21. until runmode = 0 {
  22.  
  23.     if runmode = 1 {
  24.         lock steering to UP.
  25.         set TVAL to 1.
  26.         stage.
  27.         set runmode to 2.
  28.         }
  29.        
  30.     else if runmode = 2 {
  31.         lock steering to heading (90,90).
  32.         set TVAL to 0.7.
  33.         if SHIP:ALTITUDE > 1000 {
  34.         set runmode to 3.
  35.         }
  36.         }
  37.        
  38.     else if runmode = 3 {
  39.         set targetPitch to max( 5, 90 * (1 - ALT:RADAR / 100000)).
  40.         lock steering to heading ( 90, targetPitch).
  41.         set TVAL to 0.7.
  42.        
  43.         if SHIP:GROUNDSPEED > 450 {
  44.             stage.
  45.             rcs on.
  46.             set TVAL to 0.
  47.             set runmode to 4.
  48.             }
  49.         }
  50.        
  51.     else if runmode = 4 {
  52.         lock steering to heading ( 270, 0).
  53.         if VERTICALSPEED < 1 {
  54.             ag1 on.
  55.             set TVAL to 1.
  56.            
  57.             if (SHIP:GROUNDSPEED > 500) and (SHIP:VERTICALSPEED < -100) {
  58.                 set TVAL to 0.
  59.                 set runmode to 5.
  60.                 }
  61.            
  62.             }
  63.         }
  64.        
  65.     else if runmode = 5 {
  66.         lock steering to srfretrograde.
  67.         if ship:altitude < 50000 {
  68.             set runmode to 0.
  69.             }
  70.         }
  71.        
  72.         lock throttle to TVAL.
  73.        
  74.     print "RUNMODE:     " + runmode + "         " at (5,4).
  75.     print "ALTITUDE:    " + round(SHIP:ALTITUDE) + "    " at (5,5).
  76.     print "APOAPSIS:    " + round(SHIP:APOAPSIS) + "    " at (5,6).
  77.     print "PERIAPSIS:   " + round(SHIP:PERIAPSIS) + "   " at (5,7).
  78.     print "ETA to AP:   " + round(ETA:APOAPSIS) + "     " at (5,8).
  79.    
  80. }
  81.  
  82. run gravity_calculator.
  83. run suicide_burn_calculator.
  84.  
  85. clearscreen.
  86.  
  87. wait 1.
  88. sas on.
  89.  
  90. set vLand to -4.
  91. set runmode to 7.
  92. set thrust to ship:maxthrust.
  93. set counter to 0.
  94.  
  95. lock h to alt:radar.
  96. lock vd to ship:verticalspeed.
  97. lock vDiff to (vLand - vd).
  98.  
  99. lock TimeToBurn to ((suicide_burn_calculator(1.05)-h)/vd).
  100. lock ZeroAccelThrust to ((Ship:mass*g)/thrust).
  101.  
  102. until runmode = 6 {
  103.     set g to -gravity_calculator().
  104.    
  105.     if runmode = 7 {
  106.         set TVAL to 0.
  107.         if h > 5000 {
  108.             lock steering to retrograde.
  109.             }
  110.         if h < 50000 {
  111.             ag3 on.
  112.             lock steering to srfretrograde.
  113.             set runmode to 8.
  114.             }
  115.     }
  116.    
  117.     if runmode = 8 {
  118.         if h < (suicide_burn_calculator(1.05) - vd) {
  119.             set TVAL to 1.
  120.             RCS on.
  121.             }
  122.         else {
  123.             set TVAL to 0.
  124.             }
  125.         if h/-vd < 2 {
  126.             brakes off.
  127.             }
  128.         if alt:radar < 400 {
  129.             gear on.
  130.             }
  131.         if vd > -6 {
  132.             lock steering to up.
  133.             set runmode to 9.
  134.             }
  135.         }
  136.    
  137.     if runmode = 9 {
  138.         if vDiff > 0 {
  139.             set TVAL to (ZeroAccelThrust + 0.1).
  140.             }
  141.         if vDiff < 0 {
  142.             set TVAL to (ZeroAccelThrust - 0.1).
  143.             }
  144.         if vd > -0.1 and h < 100 {
  145.             set counter to counter + 1.
  146.             wait 0.1.
  147.             }
  148.         if counter > 20 {
  149.             set runmode to 6.
  150.             }
  151.         }
  152.    
  153.     lock throttle to TVAL.
  154.    
  155.     print "Vertical Velocity:               " + round(vd, 2) + "                " at (5,4).
  156.     print "Required Burn Height:            " + round(suicide_burn_calculator(1.1), 2) + "                  " at (5,5).
  157.     print "Time to Required Burn            " + round(TimeToBurn, 2) + "        " at (5,6).
  158.     print "Runmode:                         " + runmode + "                     " at (5,7).
  159.     print "Gravitational Acceleration:      " + round(g, 2) + "                 " at (5,8).
  160.    
  161.     }
  162.  
  163. if runmode = 6 {
  164.     set TVAL to 0.
  165.     unlock throttle.
  166.     clearscreen.
  167.     print "Landing Complete" at (5,4).
  168.     wait 1.
  169.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement