Advertisement
cheeseburgerwalrus

First kOS KSP Launch Script

Nov 10th, 2015
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. //Homemade launch sequence.
  2.  
  3.  
  4. clearscreen.
  5. rcs on.
  6. sas off.
  7. lights off.
  8. ag1 on.
  9.  
  10. set targetAp to 250000. // ---- Use these to easily modify orbit parameters
  11. set targetPe to 100000. // ---- Use these to easily modify orbit parameters
  12. set targetHe to 90. // ---- Use these to easily modify orbit parameters
  13. set gTurnBegin to 2500. // ---- Use these to easily modify orbit parameters
  14. set gTurnEnd to 70000. // TODO:Figure out a use for this.
  15.  
  16. set TVAL to 1.
  17. set runmode to 1.
  18.  
  19.  
  20.  
  21. // ---- This is the ascent program.
  22.  
  23. until runmode = 0 {
  24.  
  25. if runmode = 1 { //Begin countdown
  26. print "Launch in:" at (5,11).
  27. FROM {local countdown is 5.} UNTIL countdown = 0 STEP {SET countdown to countdown - 1.} DO {
  28. print "T - " + countdown at (16,11).
  29. WAIT 1.
  30.  
  31. }
  32. set runmode to 2.
  33. }
  34.  
  35. else if runmode = 2 { //Trigger ignition, liftoff and vertical ascent before gTurnBegin
  36. lock throttle to TVAL.
  37. lock steering to heading(targetHe,90).
  38. stage.
  39. print "Initiate stage: " + stage:number at (5,17).
  40. wait until ship:altitude > gTurnBegin.
  41. set runmode to 3.
  42.  
  43. }
  44.  
  45. else if runmode = 3 { //Gravity Turn
  46. set targetPitch to max(5, 90 * (1-alt:radar / gTurnEnd)).
  47. lock steering to heading (targetHe, targetPitch). //TODO: Make this better too steep
  48. lock throttle to TVAL. //TODO: need to figure out a way to limit throttle.
  49. when ship:apoapsis >= targetAp then{ //checks for reaching target apoapsis
  50. lock throttle to 0.
  51. set runmode to 4.
  52. }
  53. }
  54.  
  55. else if runmode = 4 { //warp to apoapsis
  56. lock steering to prograde.
  57. lock throttle to 0.
  58. if eta:apoapsis >= 60 {
  59. wait 5.
  60. rcs off.
  61. set warp to 3.
  62. }
  63. else if eta:apoapsis < 60 {
  64. set warp to 0.
  65. rcs on.
  66. }
  67. when eta:apoapsis <= 10 or verticalspeed < 0 then {
  68. set runmode to 5.
  69. }
  70. }
  71.  
  72. else if runmode = 5 { //orbit insertion burn
  73.  
  74. lock steering to heading (targetHe, 0).
  75. lock throttle to 1.
  76.  
  77. when (ship:periapsis >= targetPe) or (ship:periapsis > targetAp * 0.95) then {
  78. lock throttle to 0.
  79. unlock steering.
  80. set runmode to 6.
  81. }
  82. }
  83.  
  84. else if runmode = 6 { //shutdown launch sequence
  85. UNLOCK all.
  86. SET ship:control:pilotMainThrottle TO 0.
  87. ag1 off.
  88. print "================ END LAUNCH PROGRAM ================" at (1,35).
  89. set runmode to 0.
  90. }
  91.  
  92. if stage:liquidfuel < 1 and stage:number > 0 { //stage when fuel 0
  93. print "Initiate Staging Protocal: " + stage:number.
  94. stage.
  95. print "Initiate stage: " + stage:number at (5,17).
  96. }
  97.  
  98.  
  99.  
  100.  
  101. print "Stage Number: " + stage:number + " " at (5,3).
  102. print "Runmode: " + runmode + " " at (5,4).
  103. print "Altitude: " + round(ship:altitude) + " " at (5,5).
  104. print "Apoapsis: " + round(ship:apoapsis) + " " at (5,6).
  105. print "ETA to AP: " + round(eta:apoapsis) + " " at (5,8).
  106. print "Periapsis: " + round(ship:periapsis) + " " at (5,7).
  107. print "Liquid Fuel: " + round(stage:liquidfuel) + " " at (5,9).
  108. print "Dynamic Pres: " + ship:q + " " at (5,10).
  109.  
  110.  
  111.  
  112.  
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement