Advertisement
Guest User

SRB to orbit

a guest
Jan 20th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. set ship:control:pilotmainthrottle to 0.
  2. sas on.
  3. rcs on.
  4. set tset to 0.
  5. lock throttle to tset.
  6. clearscreen.
  7. set mode to 1.
  8.  
  9. until mode = 0 {
  10. if mode = 1 {
  11. set tset to 1.
  12. print "Launch..".
  13. set mode to 2.
  14. }
  15. if mode = 2 {
  16. local altS is 1000.
  17. local altEND is body:atm:height * 0.9.
  18. local altPER is min(1, max(0,alt:radar-altS)/(altEND-altS)).
  19. local endPitch is 1.
  20. local expo is 0.7.
  21. local pitch is endPitch + (90-endPitch)*(1-altPER^(expo-(altPER/(1/expo)))).
  22. lock steering to heading(90,pitch).
  23.  
  24. if ship:altitude > 62000 {
  25. set mode to 3.
  26. }
  27. }
  28. if mode = 3 {
  29. stage.
  30.  
  31. set dV to ship:facing:vector:normalized.
  32. lock steering to lookdirup(dV,ship:facing:topvector).
  33.  
  34. local timeout is time:seconds + 9000.
  35. when dV:mag < 0.05 then set timeout to time:seconds + 3.
  36. until dV:mag < 0.02 or time:seconds > timeout {
  37. set posVec to ship:position - body:position.
  38. set vecNormal to vcrs(posVec,velocity:orbit).
  39. set vecHorizontal to -1 * vcrs(ship:position - body:position, vecNormal).
  40. set vecHorizontal:mag to sqrt(body:mu/(body:radius + ship:altitude)).
  41.  
  42. set dV to vecHorizontal - velocity:orbit.
  43. }
  44. }
  45.  
  46. //staging
  47. if stage:number > 2 {
  48. if maxthrust = 0 {
  49. stage.
  50. print "Staging-no thrust..".
  51. wait 1.
  52. }
  53. set engout to 0.
  54. list engines in engines.
  55. for eng in engines {
  56. if eng:flameout {
  57. set engout to engout + 1.
  58. }
  59. }
  60. if engout > 0 {
  61. stage.
  62. print "Staging-engine out..".
  63. wait 1.
  64. }
  65. }
  66.  
  67. //fairings
  68. if ship:altitude > 40000 {
  69. for fairing in ship:modulesnamed("ProceduralFairingDecoupler"){
  70. fairing:doevent("jettison").
  71. print "Fairing jettison.".
  72. }
  73. }
  74. wait 0.01.
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement