Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. //code originally taken from r/kos but heavily modified
  2. print "PROGRAM START".
  3.  
  4. set stageinfo to list(ship:mass, 305*9.8065, ship:partsnamed("RAPIER"):length*180, 1, 1, 9999, 9999).//this creates a dv file for use by exec.ks
  5. switch to 1.
  6. set json to list().
  7. until stage:number = json:length {
  8. json:add(list(1,1,1,1,1,1,1)).
  9. }
  10. json:add(stageinfo).
  11. writejson(json,"dv.json").
  12. switch to 0.
  13.  
  14. SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.
  15.  
  16. lock throttle to 1.
  17.  
  18. stage.
  19.  
  20. print " Throttle up".
  21. LOCK STEERING TO HEADING(90, 0).
  22.  
  23. wait until SHIP:VELOCITY:SURFACE:MAG > 80.
  24. print " Take off".
  25. LOCK STEERING TO HEADING(90, 9).
  26.  
  27. wait until SHIP:ALTITUDE > 75.//keep the plane at constant pitch to not lose any rear engines
  28. print "Retracting landing gear".
  29. GEAR OFF.
  30. wait 2.
  31. print " Climbing".
  32. LOCK STEERING TO HEADING(90, SHIP:VELOCITY:SURFACE:MAG/25).//pitch depends on speed
  33. lock throttle to 1-max((SHIP:VELOCITY:SURFACE:MAG-600)/200,0).//throttling down if speed goes too high in this phase
  34.  
  35.  
  36. wait until SHIP:ALTITUDE > 10000.
  37. print "SPEED BURN".
  38. LOCK STEERING TO HEADING(90, (12000-SHIP:ALTITUDE)/2000*SHIP:VELOCITY:SURFACE:MAG/25+(SHIP:ALTITUDE-10000)/2000*8).//this gradually pitches the ship to 8 degrees
  39. lock throttle to 1.
  40.  
  41. wait until SHIP:ALTITUDE > 12000.
  42. LOCK STEERING TO HEADING(90, 9).
  43.  
  44. wait until SHIP:ALTITUDE > 18000.
  45. print "ORBIT BURN".
  46. LOCK STEERING TO HEADING(90, 30-(28000-SHIP:ALTITUDE)/10000*22).//this gradually pitches the ship to 30 degrees
  47.  
  48. wait until ship:maxthrust < 60*ship:partsnamed("RAPIER"):length.
  49.  
  50. ag1 on.//start the rocket engine
  51. LOCK STEERING TO HEADING(90, 30).
  52. print "Waiting for orbital apoapsis".
  53.  
  54. wait until apoapsis > 75000.
  55. LOCK STEERING TO HEADING(90, 10).
  56.  
  57. lock throttle to min(max((75000-apoapsis)/50,0),1).//keeping apoapsis at 75000 despite air resistance
  58.  
  59. wait until altitude > ship:body:atm:height.
  60. run circ.
  61. run exec.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement