Advertisement
Guest User

Untitled

a guest
May 1st, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.37 KB | None | 0 0
  1. CLEARSCREEN.
  2. lights off.
  3. SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.
  4. PRINT "Countdown: -T 5 Sec".
  5. WAIT 4.
  6. FROM {local countdown is 10.} UNTIL countdown = 0 STEP {SET countdown to countdown - 1.} DO {
  7. PRINT "..." + countdown.
  8. WAIT 1.
  9. CLEARSCREEN.
  10. }
  11. LOCK THROTTLE TO 0.5.
  12. STAGE.
  13. WAIT 1.
  14. STAGE.
  15. PRINT "LIFT OFF!".
  16. lock steering to lookdirup(heading(90,85):vector, ship:facing:topvector).
  17. WAIT UNTIL SHIP:ALTITUDE > 3000.
  18. PRINT "Steering".
  19. lock steering to lookdirup(heading(90,80):vector, ship:facing:topvector).
  20. WAIT UNTIL SHIP:ALTITUDE > 4000.
  21. PRINT "Steering".
  22. lock steering to lookdirup(heading(90,75):vector, ship:facing:topvector).
  23. WAIT UNTIL SHIP:ALTITUDE > 5000.
  24. PRINT "Steering".
  25. lock steering to lookdirup(heading(90,70):vector, ship:facing:topvector).
  26. WAIT UNTIL SHIP:ALTITUDE > 6000.
  27. PRINT "Steering".
  28. lock steering to lookdirup(heading(90,65):vector, ship:facing:topvector).
  29. WAIT 3.
  30. PRINT "Waiting boosters flameout...".
  31. WAIT UNTIL STAGE:SOLIDFUEL < 0.1.
  32. lock steering to lookdirup(heading(90,45):vector, ship:facing:topvector).
  33. STAGE.
  34. PRINT "Boosters Ejected".
  35. RCS ON.
  36. PRINT "RCS ON".
  37. LOCK THROTTLE TO 0.6.
  38. PRINT "Accelerating".
  39. WAIT 5.
  40. LOCK THROTTLE TO 0.7.
  41. PRINT "Accelerating".
  42. WAIT 5.
  43. LOCK THROTTLE TO 0.8.
  44. PRINT "Accelerating".
  45. WAIT UNTIL SHIP:ALTITUDE > 30000.
  46. lock steering to lookdirup(heading(90,40):vector, ship:facing:topvector).
  47. PRINT "Steering".
  48. WAIT UNTIL SHIP:ALTITUDE > 32500.
  49. lock steering to lookdirup(heading(90,35):vector, ship:facing:topvector).
  50. PRINT "Steering".
  51. WAIT UNTIL SHIP:ALTITUDE > 35000.
  52. lock steering to lookdirup(heading(90,35):vector, ship:facing:topvector).
  53. PRINT "Steering".
  54. WAIT UNTIL SHIP:ALTITUDE > 37500.
  55. lock steering to lookdirup(heading(90,30):vector, ship:facing:topvector).
  56. PRINT "Steering a little more...".
  57. WAIT UNTIL SHIP:ALTITUDE > 40000.
  58. lock steering to lookdirup(heading(90,27):vector, ship:facing:topvector).
  59. PRINT "Still steering".
  60. WAIT UNTIL SHIP:ALTITUDE > 42500.
  61. lock steering to lookdirup(heading(90,25):vector, ship:facing:topvector).
  62. PRINT "End of turn".
  63. PRINT "Waiting apoapsis...".
  64. WAIT UNTIL SHIP:APOAPSIS > 100000.5.
  65. LOCK THROTTLE TO 0.0.
  66. PRINT "100km Apoapsis reached".
  67. WAIT 3.
  68. lock steering to prograde.
  69. PRINT "Steering to prograde".
  70. WAIT 14.
  71. PRINT "Ejecting external fueltank".
  72. STAGE.
  73. // something to turn off main engines
  74. PRINT "Turning off Main engine and setup rest".
  75. set engList to ship:partstagged("ME1").
  76. for eng in engList { set eng:thrustlimit to 0.0. }.
  77. set engList to ship:partstagged("ME2").
  78. for eng in engList { set eng:thrustlimit to 24.0. }.
  79. set engList to ship:partstagged("ME3").
  80. for eng in engList { set eng:thrustlimit to 24.0. }.
  81. WAIT 1.
  82. PRINT "Done".
  83. PRINT "waiting to exit atmosphere...".
  84. WAIT UNTIL SHIP:ALTITUDE > 70000.
  85. PRINT "Calculating maneuver node".
  86. WAIT 3.
  87. declare parameter alt.
  88. // create apoapsis maneuver node
  89. print "T+" + round(missiontime) + " Apoapsis maneuver, orbiting " + body:name.
  90. print "T+" + round(missiontime) + " Apoapsis: " + round(apoapsis/1000) + "km".
  91. print "T+" + round(missiontime) + " Periapsis: " + round(periapsis/1000) + "km -> " + round(alt/1000) + "km".
  92. // present orbit properties
  93. set vom to velocity:orbit:mag. // actual velocity
  94. set rb to body:radius. // missed lane
  95. set r to rb + altitude. // actual distance to body
  96. set ra to rb + apoapsis. // radius in apoapsis
  97. set va to sqrt( vom^2 + 2*body:mu*(1/ra - 1/r) ). // velocity in apoapsis fixed
  98. // set va to sqrt( vom^2 + 2 * mu * (1/ra - 1/r) ). // velocity in apoapsis
  99. set a to (periapsis + 2 * rb + apoapsis)/2. // semi major axis present orbit
  100. // future orbit properties
  101. set r2 to rb + apoapsis. // distance after burn at apoapsis
  102. set a2 to (alt + 2 * rb + apoapsis)/2. // semi major axis target orbit
  103. set v2 to sqrt( vom^2 + (body:mu * (2/r2 - 2/r + 1/a - 1/a2 ) ) ).
  104. // setup node
  105. set deltav to v2 - va.
  106. print "T+" + round(missiontime) + " Apoapsis burn: " + round(va) + ", dv:" + round(deltav) + " -> " + round(v2) + "m/s".
  107. set nd to node(time:seconds + eta:apoapsis, 0, 0, deltav).
  108. add nd.
  109. print "T+" + round(missiontime) + " Node created.".
  110. WAIT 4.
  111. PRINT "Node Confirmed".
  112. WAIT 2.
  113. PRINT "Prepairing for burn".
  114. // set nd to nextnode(x).
  115. print "Node in: " + round(nd:eta) + ", DeltaV: " + round(nd:deltav:mag).
  116. set max_acc to ship:AVAILABLETHRUST/ship:mass.
  117. set burn_duration to nd:deltav:mag/max_acc.
  118. print "Crude Estimated burn duration: " + round(burn_duration) + "s".
  119. wait until nd:eta <= (burn_duration/2 + 60). // nd or node
  120. lock steering to np.
  121. set np to nd:deltav.
  122. set npd to np:direction. // another missing line
  123. // wait until abs(np:pitch - facing:pitch) < 0.15 and abs(np:yaw - facing:yaw) < 0.15.
  124. wait until abs(npd:pitch - facing:pitch) < 0.1 and abs(npd:yaw - facing:yaw) < 0.1.
  125. wait until nd:eta <= (burn_duration/2). // nd or node
  126. set tset to 0.
  127. lock throttle to tset.
  128. set done to False.
  129. set dv0 to nd:deltav.
  130. until done
  131. {
  132. set max_acc to ship:AVAILABLETHRUST/ship:mass.
  133. set tset to min(nd:deltav:mag/max_acc, 1).
  134. if vdot(dv0, nd:deltav) < 0
  135. {
  136. print "End burn, remain dv " + round(nd:deltav:mag,1) + "m/s, vdot: " + round(vdot(dv0, nd:deltav),1).
  137. lock throttle to 0.
  138. break.
  139. }
  140.  
  141. //we have very little left to burn, less then 0.1m/s
  142. if nd:deltav:mag < 0.1
  143. {
  144. print "Finalizing burn, remain dv " + round(nd:deltav:mag,1) + "m/s, vdot: " + round(vdot(dv0, nd:deltav),1).
  145. //we burn slowly until our node vector starts to drift significantly from initial vector
  146. //this usually means we are on point
  147. wait until vdot(dv0, nd:deltav) < 0.5.
  148.  
  149. lock throttle to 0.
  150. print "End burn, remain dv " + round(nd:deltav:mag,1) + "m/s, vdot: " + round(vdot(dv0, nd:deltav),1).
  151. set done to True.
  152. }
  153. }
  154. unlock steering.
  155. unlock throttle.
  156. wait 1.
  157.  
  158. //we no longer need the maneuver node
  159. remove nd.
  160. lock steering to prograde.
  161. PRINT "Welcome to orbit".
  162. WAIT 4.
  163. PRINT "Lights on, debloying solar panels".
  164. panels on.
  165. lights on.
  166. WAIT 4.
  167. PRINT "You may open cargo bay now".
  168. unlock steering.
  169. WAIT 4.
  170. Print "Full control return".
  171. SAS ON.
  172. set engList to ship:partstagged("ME1").
  173. for eng in engList { set eng:thrustlimit to 0.0. }.
  174. set engList to ship:partstagged("ME2").
  175. for eng in engList { set eng:thrustlimit to 5.0. }.
  176. set engList to ship:partstagged("ME3").
  177. for eng in engList { set eng:thrustlimit to 5.0. }.
  178. print "Good bye!".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement