Advertisement
Jontu

KMun

Aug 12th, 2012
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.78 KB | None | 0 0
  1. --
  2. -- Script modified from FlyMeToTheMun by Jontu
  3. -- Original script by R4m0n
  4. --
  5. function KMunDriver(alt, lat, lon)
  6.  
  7.     if lat == "il" or lon == "il"
  8.     then
  9.     elseif math.abs(lat) > 180 or math.abs(lon) > 180
  10.         then
  11.             print "Invalid coordinates"
  12.             print "Values must be between -180 and 180"
  13.             os.exit()
  14.     end
  15.    
  16.     print "Launching..."
  17.     mechjeb.launchTo(alt*1000, 0)
  18.     wait(mechjeb.free)
  19.    
  20.     mechjeb.autoStageActivate()
  21.     print "TMI..."
  22.     mechjeb.transfer("Mun", 200000)
  23.     wait(mechjeb.free)
  24.    
  25.     print "Warping to SoI..."
  26.     mechjeb.warpToEvent("soi")
  27.     wait(mechjeb.free)
  28.    
  29.     print "Adjusting Pe..."
  30.     mechjeb.changePe(30000)
  31.     wait(mechjeb.free)
  32.    
  33.     print "Warping to Pe..."
  34.     mechjeb.warpToEvent("pe", 15)
  35.     wait(mechjeb.free)
  36.    
  37.     print "Circularizing orbit..."
  38.     mechjeb.circularize()
  39.     wait(mechjeb.free)
  40.     m = mechjeb.getModule("OrbitOper")
  41.     m.enabled = false
  42.  
  43.    
  44.     print "Landing..."
  45.     if (lat == "il" or lon == "il")
  46.     then
  47.         m = mechjeb.getModule("LandingAutopilot")
  48.         m.enabled = true
  49.         mechjeb.land()
  50.     else
  51.         mechjeb.landAt(lat, lon)
  52.     end
  53.     wait(mechjeb.free)
  54.     mechjeb.autoStageDeactivate()
  55.     print "Landed!"
  56.    
  57.     print "Attempting to stabilize..."
  58.     mechjeb.attitudeTo("up","orbit")
  59.     wait(2)
  60.     mechjeb.controlRelease()
  61.     m = mechjeb.getModule("LandingAutopilot")
  62.     m.enabled = false  
  63.     print "What now boss?"
  64. end
  65.  
  66. function KMun(alt, lat, lon)
  67.     local co = coroutine.create(KMunDriver)
  68.     coroutine.resume(co, alt, lat, lon)
  69. end
  70.  
  71. print "Usage: KMun(alt, lat, lon)"
  72. print "Alt is Kerbin Orbit Altitude in km"
  73. print "lat and lon are landing coordinates"
  74. print "Valid coordinates are -180 to 180 or il (in quotes) for immediate landing"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement