Advertisement
mager42

spmunksc 1.0

Aug 18th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.47 KB | None | 0 0
  1. -- VTOL start Mun Space Plane From Muun To KSC /Horizontal Land/
  2. -- it is better start when KSC is on oposite side od kerbin from muun
  3. -- spmunksc 1.0
  4. -- script written by mager42
  5. -- script partialy based off shtutle land by olex
  6. -- credits to olex and r4m0n
  7.  
  8.  
  9. function GoKSCDriver(ArPe, offset)
  10.  
  11.     if (ArPe == nil) then
  12.         ArPe = 31
  13.     end
  14.  
  15.  
  16.     print "Start to to parking orbit"
  17.     mechjeb.launchTo(21000 , -180)
  18.     wait(mechjeb.free)
  19.     print "Orbiting"
  20.  
  21.     print "Go to inclination change point, u can warp but must stop warp before Equator"
  22.  
  23.     if vessel.latitude < 0 then
  24.  
  25.         while vessel.latitude < (-0.8) do
  26.         wait(3)
  27.         end
  28.  
  29.         print "Start inclination change"
  30.         mechjeb.attitudeTo("left", "ORBIT")
  31.         wait(12)
  32.         mechjeb.thrustActivate(10)
  33.  
  34.         while vessel.orbitInclination < 179.1 do
  35.         wait(0.5)
  36.         end
  37.         mechjeb.thrustDeactivate()
  38.  
  39.     else
  40.  
  41.         while vessel.latitude > 0.8 do
  42.         wait(3)
  43.         end
  44.  
  45.         print "Start inclination change"
  46.         mechjeb.attitudeTo("rigth", "ORBIT")
  47.         wait(12)
  48.         mechjeb.thrustActivate(10)
  49.  
  50.         while vessel.orbitInclination > 0.9 do
  51.         wait(0.5)
  52.         end
  53.         mechjeb.thrustDeactivate()
  54.  
  55.     end
  56.  
  57.     print "Inclination Changed"
  58.  
  59.     print "Go to escape burn point, u can warp but must stop warp before -120 N"
  60.  
  61.     while vessel.longitude > (-123) do
  62.         wait(3)
  63.     end
  64.  
  65.     print "Start escape burn"
  66.     mechjeb.attitudeTo("forward", "ORBIT")
  67.     wait(14)
  68.     mechjeb.thrustActivate(100)
  69.  
  70.     while vessel.speedOrbital < 800 do
  71.         wait(0.5)
  72.     end
  73.     mechjeb.thrustDeactivate()
  74.     mechjeb.thrustActivate(10)
  75.     while vessel.speedOrbital < 842 do
  76.         wait(0.5)
  77.     end
  78.     mechjeb.thrustDeactivate()
  79.    
  80.     print "warp out off Muun SOI"
  81.     mechjeb.warpToEvent("SoI")
  82.     wait(mechjeb.free)
  83.     wait(1)
  84.  
  85.  
  86.     print "Lovering PE"
  87.     mechjeb.attitudeTo("back", "ORBIT_HORIZONTAL")
  88.     wait(12)
  89.     mechjeb.changePe(ArPe * 1000)
  90.     wait(mechjeb.free)
  91.     wait(1)
  92.  
  93.  
  94.     print "Start Landing Program"
  95.  
  96.     -- KSP coordinates
  97.     lat = -0.103
  98.     lon = -74.575
  99.  
  100.     if (offset == nil) then
  101.         offset = 132 -- default offset
  102.     end
  103.  
  104.     lon = lon - (offset / 10) -- 1° ~= 10km near the KSP
  105.    
  106.     slope = 3
  107.    
  108.    
  109.     -- start re-entry sequence
  110.  
  111.  
  112.     --first areobrake
  113.     mechjeb.warpToEvent("Pe")
  114.     while vessel.altitudeASL > 75000 do
  115.     wait(3)
  116.     end
  117.     mechjeb.controlRelease()
  118.  
  119.     print "Areobraking"
  120.     wait(8)
  121.     mechjeb.attitudeTo({0,0,0,0}, "ORBIT_HORIZONTAL")
  122.  
  123.     while vessel.altitudeASL > 55000 do
  124.     wait(5)
  125.     end
  126.  
  127.     print "."
  128.     mechjeb.attitudeTo({0,6,10}, "ORBIT_HORIZONTAL")
  129.  
  130.     while vessel.altitudeASL < 70000 do
  131.     wait(5)
  132.     end
  133.     print "Warp to Ap"
  134.     mechjeb.warpToEvent("Ap")
  135.     wait(mechjeb.free)
  136.  
  137.     print "Adjust PE"
  138.     mechjeb.attitudeTo("forward", "ORBIT_HORIZONTAL")
  139.     wait(8)
  140.     mechjeb.changePe(70000)
  141.     wait(mechjeb.free)
  142.  
  143.     print "Deorbiting..."
  144.     mechjeb.landAt(lat, lon, false)
  145.     wait(111)
  146.    
  147.    
  148.  
  149.     mechjeb.warpToEvent("Pe")
  150.    
  151.     -- at 75km
  152.     while vessel.altitudeASL > 75000 do
  153.         wait(4)
  154.     end
  155.     print "Beginning re-entry, hold onto something..."
  156.     mechjeb.controlRelease()
  157.     wait(8)
  158.     mechjeb.attitudeTo({0,0,0,0}, "ORBIT_HORIZONTAL")
  159.  
  160.     -- at 55km
  161.     while vessel.altitudeASL > 55000 do
  162.         wait(4)
  163.     end
  164.  
  165.     print "."
  166.     mechjeb.attitudeTo({0,5,10}, "ORBIT_HORIZONTAL")
  167.  
  168.     -- at 18km
  169.     while vessel.altitudeASL > 19000 do
  170.         wait(4)
  171.     end
  172.  
  173.     print "."
  174.     mechjeb.attitudeTo({0,2,10}, "ORBIT_HORIZONTAL")
  175.  
  176.  
  177.        
  178.     -- at 15km: engage the ILS
  179.     while vessel.altitudeASL > 16000 do
  180.         wait(3)
  181.     end
  182.     print "Initiating ILS approach, please lower landing gear manually."
  183.     ils = mechjeb.getModule("ils")
  184.     ils.glideslope = slope
  185.     mechjeb.ilsLand()
  186.     mechjeb.thrustActivate(8)
  187.     -- at 180
  188.     while vessel.altitudeTrue > 180 do
  189.         wait(3)
  190.     end
  191.     print "Shut Down Engines."
  192.     mechjeb.thrustDeactivate()
  193.     -- at 6m (immediately before touchdown)
  194.     while vessel.altitudeTrue > 6 do
  195.         wait(3)
  196.     end
  197.     print "Touching down, You can hit the brakes now."
  198.     wait(3)
  199.     mechjeb.controlRelease() -- stop ILS sequence
  200.     mechjeb.attitudeTo({1,0,0,0}, "SURFACE_NORTH")
  201.     mechjeb.stage() -- in case there actually are braking chutes
  202.    
  203.     -- at <2 m/s, we're done
  204.     while vessel.speedSurface > 2 do
  205.         wait(4)
  206.     end
  207.     print "Welcome home. Roll out off runway"
  208.     mechjeb.attitudeTo("back", "SURFACE_NORTH")
  209.     wait(42)
  210.     mechjeb.controlRelease()
  211.     print "End of roll."
  212.  
  213.  
  214. end
  215.  
  216. function goksc(ArPe, offset)
  217.     local co = coroutine.create(GoKSCDriver)
  218.     coroutine.resume(co, ArPe, offset)
  219. end
  220.  
  221. print "Usage: goksc(AeroBrake Pe, Landing offset) - default 31km, 132km"
  222. print "Set Ascent A. to start turn at 0km, end at 20km"
  223. print " and stop staging before stage with chute"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement