Advertisement
mager42

spmunksc 1.1

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