Advertisement
Guest User

Untitled

a guest
Nov 27th, 2015
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. CLEARSCREEN.
  2.  
  3.  
  4.  
  5.  
  6. SET linepos TO 11. //line at wich the fluight log will start printing events.
  7.  
  8. //circularization burn req calculations here!
  9. //declaring variables
  10.  
  11. SET launched TO false.
  12. SET burntime to 99999.
  13. SET launchcompleted TO false.
  14.  
  15. PRINT "Flight status: " AT(0,0).
  16. PRINT "Apoapsis: " AT(0,1).
  17. PRINT "Orbital Velocity: " AT (0,2).
  18. PRINT "Req.dV for Circ.: " AT(0,3).
  19. PRINT "burntime: " AT(0,4).
  20.  
  21.  
  22. PRINT "Flight log: " AT(0,10).
  23.  
  24. PRINT "Counting down to launch." AT(16,0).
  25.  
  26. //Next, we'll lock our throttle to 100%
  27. LOCK THROTTLE TO 1.0. //1.0 is the max, 0.0 is idle.
  28.  
  29. //this is our countdown loop, wich cycles from 10 to 0.
  30. FROM {LOCAL countdown is 3.} UNTIL countdown = 0 STEP {SET countdown to countdown - 1.} DO {
  31. PRINT countdown AT(0,linepos).
  32. SET linepos TO linepos + 1.
  33. Wait 1. //Pauses script here for 1 second.
  34. }
  35.  
  36. //running this program will update burnreqs
  37. FUNCTION setcalc {
  38.  
  39.  
  40.  
  41. SET mu TO KERBIN:MU.
  42. SET sma TO ORBIT:SEMIMAJORAXIS.
  43. SET r TO KERBIN:RADIUS + SHIP:ALTITUDE.
  44. SET rapo TO KERBIN:RADIUS + SHIP:APOAPSIS.
  45. SET a TO ( mu / ( r ^ 2 ) ).
  46. SET aapo TO ( mu / ( rapo ^ 2 ) ).
  47. SET v to SQRT( a * r ).
  48. SET vapo to SQRT( aapo * rapo ).
  49. SET orbvel TO SQRT( mu * ( ( 2 / r ) - ( 1 / sma ) ) ).
  50. SET orbvelapo TO SQRT( mu * ( ( 2 / rapo ) - ( 1 / sma ) ) ).
  51. SET burnvel TO v.
  52. SET burnvelapo TO vapo.
  53. SET burnreq TO burnvelapo - orbvelapo.
  54.  
  55.  
  56.  
  57. }
  58.  
  59.  
  60. FUNCTION softstage {
  61.  
  62. LOCK THROTTLE TO 0.0.
  63. WAIT 0.2.
  64. LOCK THROTTLE TO 0.1.
  65. WAIT 0.2.
  66. LOCK THROTTLE TO 0.2.
  67. WAIT 0.2.
  68. LOCK THROTTLE TO 0.3.
  69. WAIT 0.2.
  70. LOCK THROTTLE TO 0.4.
  71. WAIT 0.2.
  72. LOCK THROTTLE TO 0.5.
  73. WAIT 0.2.
  74. LOCK THROTTLE TO 0.6.
  75. WAIT 0.2.
  76. LOCK THROTTLE TO 0.7.
  77. WAIT 0.2.
  78. LOCK THROTTLE TO 0.8.
  79. WAIT 0.2.
  80. LOCK THROTTLE TO 0.9.
  81. WAIT 0.2.
  82. LOCK THROTTLE TO 1.0.
  83.  
  84. }
  85.  
  86. FUNCTION calc_burn {
  87. SET max_acc TO SHIP:MAXTHRUST/SHIP:MASS.
  88. SET burntime TO burnreq/max_acc.
  89. }
  90.  
  91. FUNCTION circularize {
  92. LOCK STEERING TO HEADING(90,0).
  93. UNTIL PERIAPSIS > 99999 {
  94. LOCK THROTTLE TO 1.0.
  95. }
  96. LOCK throttle TO 0.0.
  97. PRINT "Circularization complete." AT(0,linepos).
  98. }
  99.  
  100. WHEN SHIP:ALTITUDE < 250 AND MAXTHRUST = 0 THEN {
  101.  
  102. PRINT "Staging." AT(0,linepos).
  103. SET linepos TO linepos + 1.
  104. STAGE.
  105. SET launched TO true.
  106. PRESERVE.
  107. }
  108.  
  109. WHEN SHIP:ALTITUDE >= 250 AND MAXTHRUST = 0 THEN {
  110. PRINT "Staging." AT(0,linepos).
  111. SET linepos TO linepos + 1.
  112. STAGE.
  113. PRESERVE.
  114. }
  115.  
  116.  
  117.  
  118.  
  119.  
  120. UNTIL PERIAPSIS > 97500 {
  121.  
  122. setcalc().
  123. PRINT ROUND(burnreq) AT(18,3).
  124. PRINT ROUND(orbvel) AT(19,2).
  125. PRINT burntime AT(11,4).
  126. IF launched = true {
  127. calc_burn().
  128. }
  129.  
  130. IF ETA:APOAPSIS < (0.5*burntime) AND launchcompleted = true {
  131. PRINT "Starting Circularization" AT(16,0).
  132. circularize.
  133. BREAK.
  134. }
  135. UNTIL APOAPSIS > 100000 {
  136.  
  137. IF launched = true {
  138. calc_burn().
  139. }
  140.  
  141. setcalc().
  142. PRINT ROUND(burnreq) AT(18,3).
  143. PRINT ROUND(orbvel) AT(19,2).
  144. IF SHIP:VELOCITY:SURFACE:MAG < 100 {
  145. LOCK STEERING TO HEADING(90,90).
  146. PRINT "Pitching to 90 degrees." AT(16,0).
  147. PRINT ROUND(orbvel) AT(19,2).
  148. PRINT ROUND(burnreq) AT(18,3).
  149. PRINT burntime AT(11,4).
  150.  
  151. } ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 100 AND SHIP:VELOCITY:SURFACE:MAG < 200 {
  152. LOCK STEERING TO HEADING(90,80).
  153. PRINT "Pitching to 80 degrees." AT(16,0).
  154. PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
  155. PRINT ROUND(orbvel) AT(19,2).
  156. PRINT ROUND(burnreq) AT(18,3).
  157. PRINT burntime AT(11,4).
  158.  
  159. } Else IF SHIP:VELOCITY:SURFACE:MAG >= 200 AND SHIP:VELOCITY:SURFACE:MAG < 300 {
  160. LOCK STEERING TO HEADING(90,70).
  161. PRINT "Pitching to 70 degrees." AT(16,0).
  162. PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
  163. PRINT ROUND(orbvel) AT(19,2).
  164. PRINT ROUND(burnreq) AT(18,3).
  165. PRINT burntime AT(11,4).
  166.  
  167. } Else IF SHIP:VELOCITY:SURFACE:MAG >= 300 AND SHIP:VELOCITY:SURFACE:MAG < 400 {
  168. LOCK STEERING TO HEADING(90,60).
  169. PRINT "Pitching to 60 degrees." AT(16,0).
  170. PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
  171. PRINT ROUND(orbvel) AT(19,2).
  172. PRINT ROUND(burnreq) AT(18,3).
  173. PRINT burntime AT(11,4).
  174.  
  175. } Else IF SHIP:VELOCITY:SURFACE:MAG >= 400 AND SHIP:VELOCITY:SURFACE:MAG < 500 {
  176. LOCK STEERING TO HEADING(90,50).
  177. PRINT "Pitching to 50 degrees." AT(16,0).
  178. PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
  179. PRINT ROUND(orbvel) AT(19,2).
  180. PRINT ROUND(burnreq) AT(18,3).
  181. PRINT burntime AT(11,4).
  182.  
  183. } Else IF SHIP:VELOCITY:SURFACE:MAG >= 500 AND SHIP:VELOCITY:SURFACE:MAG < 600 {
  184. LOCK STEERING TO HEADING(90,40).
  185. PRINT "Pitching to 40 degrees." AT(16,0).
  186. PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
  187. PRINT ROUND(orbvel) AT(19,2).
  188. PRINT ROUND(burnreq) AT(18,3).
  189. PRINT burntime AT(11,4).
  190.  
  191. } Else IF SHIP:VELOCITY:SURFACE:MAG >= 600 AND SHIP:VELOCITY:SURFACE:MAG < 700 {
  192. LOCK STEERING TO HEADING(90,30).
  193. PRINT "Pitching to 30 degrees." AT(16,0).
  194. PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
  195. PRINT ROUND(orbvel) AT(19,2).
  196. PRINT ROUND(burnreq) AT(18,3).
  197. PRINT burntime AT(11,4).
  198.  
  199. } Else IF SHIP:VELOCITY:SURFACE:MAG >= 700 AND SHIP:VELOCITY:SURFACE:MAG < 800 {
  200. LOCK STEERING TO HEADING(90,20).
  201. PRINT "Pitching to 20 degrees." AT(16,0).
  202. PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
  203. PRINT ROUND(orbvel) AT(19,2).
  204. PRINT ROUND(burnreq) AT(18,3).
  205. PRINT burntime AT(11,4).
  206.  
  207. } Else IF SHIP:VELOCITY:SURFACE:MAG >= 800 {
  208. LOCK STEERING TO HEADING(90,10).
  209. PRINT "Pitching to 10 degrees." AT(16,0).
  210. PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
  211. PRINT ROUND(orbvel) AT(19,2).
  212. PRINT ROUND(burnreq) AT(18,3).
  213. PRINT burntime AT(11,4).
  214.  
  215. }
  216. }
  217. LOCK THROTTLE TO 0.0.
  218. LOCK STEERING TO HEADING(90,0).
  219. PRINT "Apoapsis of 100km reached." AT(0,linepos).
  220. SET launchcompleted TO true.
  221. }
  222. PRINT "In orbit. Have a nice flight!" AT(16,0).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement