Advertisement
Guest User

Untitled

a guest
Oct 15th, 2013
1,565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.49 KB | None | 0 0
  1. clearscreen.
  2. sas off. // Ensures SAS is OFF.
  3.  
  4. //**User Set variables.
  5.  
  6. set tOrbit to 100000. // Sets Default Target Orbit.
  7. set tHeading to 90. // Sets your launch heading. Usage:0-360. 0=North.
  8. set rpAlt to 1000. // Sets the altitude at which to preform an initial roll.
  9. set rProgram to -90. // Sets the roll target. Engages at rpAlt. Usage:0-360. 180=VAB default.
  10.  
  11. set throttleLimit to 1. // Engages throttle limits below turn1.
  12. set tTWR to 2. // Sets the max TWR while throttle limited.
  13.  
  14. set Count to 0. // Sets the number of asparagus stages.
  15. set aspFuel to 0. // Sets the amount of fuel in one aparagus stage.
  16.  
  17.  
  18. //**Internal variables.
  19.  
  20. set yaw to 90 + tHeading. // Internal var to match heading to NavBall
  21. set pitch to 90. // Sets your inital pitch via heading. Usage:0-360 90=Up.
  22. set roll to 180. // Sets your inital roll. Usage:0-360. 180=VAB Default.
  23. set x to 0. // Internal var for angle calculation.
  24. set y to 0. // Internal var for angle calculation.
  25. set z to 0. // Internal var for angle calculation.
  26. set tThr to 1. // Sets throttle at lift off.
  27. lock steering to up + R(0,0,roll) + V(x,y,z). // Locks steering to calculated vector plus roll.
  28. lock throttle to tThr. // Locks throttle to var tThr.
  29. set orbit to 0. // Sets the main loop close condition.
  30. set hAtmo to 69500. // Sets the altitude of atmosohere of Kerbin. Unit:Meters.
  31. set turn1 to 9999. // Sets the altitude of the first down range turn. Unit:Meters
  32. set turn2 to 14999. // " " Unit:Meters
  33. set turn3 to 19999. // " " Unit:Meters
  34. set turn4 to 24999. // " " Unit:Meters
  35. set turn5 to 49999. // " " Unit:Meters
  36. set end to 0. // Internal var for UI.
  37. set bitMask to " ". // Internal var for UI.
  38. set printflag to 1. // Internal var for UI.
  39. if ag9 = "True" { toggle ag9. }. // Internal var for UI.
  40. if ag8 = "True" { toggle ag8. }. // Internal var for UI.
  41. if ag7 = "True" { toggle ag7. }. // Internal var for UI.
  42. set TWR to (maxthrust/(mass*9.81)). // Preliminary TWR set.
  43.  
  44. //**Abort Procedure.
  45. // Usage: AG2 decople/fire escape motors. AG3 decouple tower/trigger parachute.
  46. on abort { toggle ag2. wait until verticalspeed < 0. toggle ag3. }.
  47.  
  48.  
  49. //**UI Section.
  50.  
  51. until end = 1
  52. {
  53. if ag9 = "True" { set tOrbit to tOrbit + 10000. set printflag to 1. toggle ag9. }.
  54. if ag8 = "True" { set tOrbit to tOrbit - 10000. set printflag to 1. toggle ag8. }.
  55. if tOrbit < 80000 { set tOrbit to 80000. }.
  56. if tOrbit > 650000 { set tOrbit to 650000. }.
  57. if ag7 = "True"
  58. {
  59. clearscreen.
  60. print "You have confirmed " + tOrbit + "m" at (0,1).
  61. print "Lift Off in 5s." at (0,3).
  62. toggle ag7.
  63. wait 2.
  64. set end to 1.
  65. }.
  66.  
  67. if printflag = 1
  68. {
  69. clearscreen.
  70. print "Select your orbit altitude." at (0,0).
  71. print "--------------------------------" at (0,1).
  72. print "Use action group 9 to add 10Km to orbit alt." at (0,3).
  73. print "Use action group 8 to remove 10Km from orbit alt." at (0,5).
  74. print "Use action group 7 to confirm orbit alt." at (0,7).
  75. print "You have selected " + tOrbit + "m" at (0,9).
  76. set printflag to 0.
  77. }.
  78. }.
  79.  
  80.  
  81. //**Throttle limit section.
  82. //**Learned a new way to lock TWR that is faster and doesn't need to be in the loop.
  83. //**Thanks to KSP forum member Check for this better method.
  84.  
  85. if throttleLimit = 1
  86. {
  87. lock throttle to (tTWR * 9.81 * mass / maxthrust).
  88. when altitude > turn1 then
  89. { set throttleLimit to 0. lock throttle to tThr. }.
  90. }.
  91.  
  92.  
  93. //**Values based on UI.
  94.  
  95. set xAlt to tOrbit - 100. // Primary M.E.C.O. Condition. Usage:xAlt=tOrbit-Meters.
  96. set xOrbit to tOrbit + 5000. // Secondary M.E.C.O. Condition. Usage:xOrbit=tOrbit+Meters.
  97. set cAlt to (tOrbit - (tOrbit*.01)). // Internal var for near MECO throttle limit. Usage:cAlt=tOrbit-5%.
  98. set hAlt to tOrbit - 5. // Internal var for apoaps hold. Usage:hAlt=tOrbit-Meters.
  99.  
  100.  
  101. //**Begin Countdown.
  102.  
  103. clearscreen.
  104. print "Orbit altitude set to " + tOrbit + "m".
  105. print "3". wait 1.
  106. print "2". wait 1.
  107. print "1". wait 1.
  108. clearscreen.
  109. print "Lift Off! Target Heading set to " + tHeading + "Deg". stage.
  110.  
  111. set StartFuel to <liquidfuel>. // Internal var for initial Total Liquid Fuel.
  112.  
  113.  
  114. //**G-turn Section.
  115.  
  116. when altitude > rpAlt then set roll to rProgram.
  117. when altitude > turn1 then set pitch to 60.
  118. when altitude > turn2 then set pitch to 50.
  119. when altitude > turn3 then set pitch to 30.
  120. when altitude > turn4 then set pitch to 15.
  121. when apoapsis > turn5 then set pitch to 0.
  122.  
  123.  
  124. //**Orbit Injection control. Alter at your own risk.
  125.  
  126. when apoapsis > tOrbit then
  127. {
  128. set tThr to 0.
  129. toggle ag5.
  130. until altitude > hAtmo
  131. {
  132. if apoapsis < hAlt { set tThr to .1. }.
  133. if apoapsis > tOrbit { set tThr to 0. }.
  134. }.
  135. }.
  136. when altitude > 70200 then
  137. {
  138. set Gk to 3.5316000*10^12.
  139. set Radius to 600000 + apoapsis.
  140. set sma to 600000 + ((periapsis+apoapsis)/2).
  141. set V1 to (Gk/Radius)^.5.
  142. set V2 to (Gk*((2/Radius)-(1/sma)))^.5.
  143. set dV to abs(V1-V2).
  144. set acceleration to (maxthrust/mass).
  145. set burnTime to (dV/acceleration).
  146. set tTime to (burnTime/2).
  147. set warp to 3.
  148. when eta:apoapsis < (120 + tTime) then set warp to 2.
  149. when eta:apoapsis < (60 + tTime) then
  150. { set warp to 0. wait 1. lock steering to prograde. }.
  151. when eta:apoapsis < tTime then set tThr to 1.
  152. when periapsis > cAlt then set tThr to .1.
  153. when periapsis > xAlt OR apoapsis > xOrbit then
  154. {
  155. set tThr to 0.
  156. sas on.
  157. clearscreen.
  158. print "You Are Now In Orbit".
  159. set orbit to 1.
  160. }.
  161. }.
  162.  
  163.  
  164. //**Main Control loop. Alter at your own risk.
  165.  
  166. until orbit = 1
  167. {
  168. set x to cos(yaw) * cos(pitch).
  169. set y to sin(yaw) * cos(pitch).
  170. set z to sin(pitch).
  171. set StageSolid to stage:solidfuel.
  172. set StageLiquid to stage:liquidfuel.
  173. set Lfuel to <liquidfuel>.
  174. set TWR to maxthrust / (mass*9.81).
  175. if throttle < 1 { set cTWR to (TWR*throttle). }.
  176. if throttle > 1 OR throttle = 1 { set cTWR to TWR. }.
  177. print "Heading " + heading + bitMask at (0,3).
  178. print "Max Surface TWR " + TWR + bitMask at (0,5).
  179. print "Current TWR " + cTWR + bitMask at (0,7).
  180. print "ETA:Apoapsis " + eta:apoapsis + bitMask at (0,9).
  181. print "MaxThrust " + maxthrust + "kN" + bitMask at (0,11).
  182.  
  183. if Lfuel < (StartFuel - aspFuel) AND Count > 0
  184. { stage. set StartFuel to (StartFuel-aspFuel). set Count to Count - 1. }.
  185.  
  186. if StageSolid < 1 AND StageSolid > 0
  187. { stage. }.
  188.  
  189. if StageLiquid = 0 AND StageSolid = 0
  190. { if Lfuel > 0 { stage. wait 1. }. }.
  191. }.
  192.  
  193. //**End program orbital condition print out. Extend solar pannels on AG1.
  194.  
  195. lock throttle to 0.
  196. wait 1.
  197. toggle ag1.
  198. print " ".
  199. print "Apoapsis is " + apoapsis + "m".
  200. print " ".
  201. print "Periapsis is " + periapsis + "m".
  202. print " ".
  203. print "Orbital Eccentricity is " +
  204. (((apoapsis + 600000)-(periapsis + 600000))/((apoapsis + 600000)+(periapsis + 600000))).
  205. print " ".
  206. wait 2.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement