KOS Wiki
Register
Advertisement

by TheGreatFez taken from Reddit with permission.

Summary[]

Developed under kOS 0.7 This program is actually a set of 7 programs. The "fun" program in the folder is the one that runs them all. By changing the staging sequences inside the program you can actually run this with a variety of ships, I made it so it can be used with (virtually) any ship with small changes to some variables.

I have spent about 30 hours of testing and 2 weeks working on this, so any feedback would be appreciated! Its extremely complicated and the code is quite long (807 lines in total to be exact) but I did my best to comment on what is going on. If you would like to know more please feel free to ask! Here is a list of what the program does:

  1. Launches from Kerbin using optimal Aerodynamic speeds and asparagus staging to get to a 150Km orbit.
  2. Using MatLab I determine the launch phase angle to intercept Mun. I used a flag placed on the 47o longitude 0o latitude to determine phase angle.
  3. Circularized orbit upon reaching Mun.
  4. Killed all speed and decended straight down.
  5. Touchdown on Mun.
  6. Re launch from Mun to 100Km circular parking orbit.
  7. Used MatLab again to calculate Delta-V and the Burn Longitude to get back to Kerbin with a 30Km Periapsis.
  8. Warp to atmosphere and deploy parachute.

Sometimes the lander falls over on the Mun, slopes are the worst.

The mentioned Mathlab scripts are not written in Kerboscript and were used to generated values which are used in the Kerboscript scripts.

How to use:[]

Copy all files into your Archive folder. Note: It may still work now but its always better to copy them into your local vehicle drive (from the archive). run fun. Enjoy the show.

The Files:[]

Note: This file is publicly editable and might contain malicious code.
Please exercise caution when using.
fun.txt view
[]

set x to 150000.
set y to 2.
set z to 7.
run circularize(x,y,z).
run PhaseI.
run PhaseII.
run PhaseIII.
wait 10.
run PhaseIV.
run PhaseV.
run Reentry.

Please Don't Edit This

Note: This file is publicly editable and might contain malicious code.
Please exercise caution when using.
Circularize.txt view
[]




 // Set FINAL to your desired circular orbit.
 declare parameter FINAL,asp,staging.

 stage.
 set thrust to 0.
 lock throttle to thrust.
 lock steering to up + R(0,0,180).

 set m to mass.
 set Qmax to .5*1.2*(100.9^2).
 set Cd to .20075*.008.
 set D to (mass*9.81)/Qmax.

 clearscreen.
 sas on.
 print "T-minus 5". wait 1.
 print "4". wait 1.
 print "3". wait 1.
 print "2". wait 1.
 print "1". wait 1.
 print "Launch".
 set thrust to 1.
 stage.
 set staging to staging-1.
 if stage:solidfuel > 0 {
 	set BoosterStage to 1.
 	}.
 if stage:solidfuel < 1 {
 	set BoosterStage to 0.
 	}.
 print "BoosterStage " + BoosterStage.
 print "Asparagus " +asp.
 wait 1.
 clearscreen.
 set p0 to 1.223125.
 set e to 2.71828.
 set q to 0.
 print "Vertical Ascent" at (0,0).
 print "Q-Max" at (0,1).
 print "Dynamic Pressure" at (0,2).
 set GM to 3.5316*(10^12).
 until q > Qmax*.5 {
 	set thrust to .9.
 	set H to altitude/(-5000).
 	set p to p0*(e^H).
 	set r to altitude+600000.
 	set g to GM/(r^2).
 	set Qmax to g/Cd.
 	set q to .5*p*(verticalspeed^2).
 	print Qmax at (20,1).
 	print q at (20,2).
 	}.
 // Throttle is reduced to maintain a constant terminal velocity.
 clearscreen.
 print "Throttle down to reduce drag losses" at (0,0).
 print "Throttle" at (0,1).
 print "Q-Max" at (0,2).
 print "Dynamic Pressure" at (0,3).
 print "Aerodynimc Eff. " at (0,4).
 set x to .5.
 until altitude > 25000 {
 	set H to altitude/(-5000).
 	set I to altitude/(10000).
 	set delta to (e^I)*(-1).
 	set p to p0*(e^H).
 	set r to altitude+600000.
 	set g to GM/(r^2).
 	set Qmax to g/Cd.
 	set vsurf to velocity:surface.
 	set Vsx to vsurf:x.
 	set Vsy to vsurf:y.
 	set Vsz to vsurf:z.
 	set Vs2 to (Vsx^2)+(Vsy^2)+(Vsz^2).	
 	set q to .5*p*(vs2).
 	set err to .002.
 	set error to 1-err*(q-Qmax).
 	set Drag to ((Qmax*Cd*mass)/maxthrust).
 	set Weight to (mass*g)/maxthrust.
 	set tThrust to (Drag+ Weight)*error.
 	lock steering to up + R(0,delta,180).
 	if tThrust > .85 {
 		set thrust to .85.
 		}
 	if tThrust < .85 {
 		set thrust to tThrust.
 		}.
 	if altitude > 10000 AND x < 1 {
 		sas off.
 		print "Begin gravity turn" at (0,7).
 		set x to x+1.
 		}.
 	print thrust*100+"%" at (20,1).	
 	print Qmax at (20,2).
 	print q at (20,3).
 	print (100*(q/Qmax)) at (20,4).
 	if stage:solidfuel = 0 AND BoosterStage = 1{
 		stage.
 		set staging to staging-1.
 		set BoosterStage to 0.
 		}.
 	set FUEL to 3600+2880*2*(asp-1).
 	if stage:liquidfuel < FUEL AND asp > 0 {
 		stage.
 		set staging to staging-1.
 		set asp to asp - 1.
 		}.
 	if stage:liquidfuel = 0 AND staging > 1 {
 		stage.
 		set staging to staging-1.
 		wait 1.
 		}.
 	}.
 // After 25,000m the effects of drag are minimal so thrust is set to 100%.
 // Burn to desired circular orbit altitude.

 clearscreen.
 print "Burn to " + FINAL*.001 + "Km Apogee".
 set thrust to .85.
 set x to 0.
 until apoapsis > FINAL AND altitude > 70000 {
 	if delta > (-90) {
 		set I to altitude/(10000).
 		set delta to (e^I)*(-1).
 		if delta < (-90) {
 			set delta to (-90).
 			}.
 		}.
 		lock steering to up + R(0,delta,180).
 	if apoapsis > .9*FINAL AND x = 0{
 		set thrust to (10*mass)/maxthrust.
 		set x to 1.
 		}.
 	if apoapsis >.99*FINAL AND x = 1 {
 		set thrust to mass/maxthrust.
 		}.
 	if apoapsis > FINAL {
 		set thrust to 0.
 		}.
 	if stage:liquidfuel = 0 {
 		stage.
 		}.
 	}.
 set thrust to 0.
 clearscreen.

 //Calculate circular velocity at apoapsis altitude
 set x to 1.
 set GM to 3.5316*(10^12).
 set r to apoapsis+600000.
 set vcir to (GM/r)^.5.
 set v to 0.
 set per to periapsis+600000.
 set a to (r+per)/2.
 set e to (r-per)/(r+per).
 set h to (GM*a*(1-(e^2)))^.5.
 set Va to h/r.
 set ar to (Va^2)/r.
 set g to GM/(r)^2.
 set W to mass*(g-ar).
 set theta to arcsin(W/maxthrust).

 // Warp!
 print "Warp to Apogee".
 print theta.
 set warp to 4.
 wait until eta:apoapsis < 1000.
 set warp to 3.
 wait until eta:apoapsis < 50.
 set warp to 0.
 lock steering to heading 90 by theta.
 clearscreen.

 // Waiting on apoapsis arrival.
 print "Vertical Speed" at (0,1).
 until verticalspeed < 0 {
 	print verticalspeed at (20,1).
 	print "T-minus " + eta:apoapsis + " to Apoapsis" at (0,0).
 	}.
 clearscreen.

 // Burn to circularize, theta is used to maintain the apogee infront of the craft
 print "Burn to Circularize Orbit" at (0,0).
 print "Vertical Speed" at (0,1).
 print "Orbital Speed" at (0,2).
 print "Vcir" at (0,3).
 print vcir at (20,3).
 print "Theta" at (0,4).
 print theta at (20,4).
 set y to .5.
 set Vo to 0.
 set z to 0.
 set x to 1.
 until vcir-Vo < .001 {
 	set thrust to x.
 	set vorbit to velocity:orbit.
 	set Vox to vorbit:x.
 	set Voy to vorbit:y.
 	set Voz to vorbit:z.
 	set Vo to ((Vox^2)+(Voy^2)+(Voz^2))^.5.
 	set ar to (Vo^2)/r.
 	set W to mass*(g-ar).

 if y = .5 {
 		set err to .75.
 		set error to 1-(err*verticalspeed).
 		set theta to arcsin(W/maxthrust).
 		set theta to theta*error.
 		}.
 	if stage:liquidfuel = 0 AND z < 1{
 		stage.
 		set z to 1.5.
 		}.
 	if (Vcir-Vo) < 100  AND y < 1{
 		set err to 2.5.
 		set A to 10.
 		set y to y+1.
 		}.
 	if (Vcir-Vo) < 10 AND y < 2{
 		set err to 5.
 		set A to 1.
 		set y to y+1.
 		}.
 	if (Vcir-Vo) < 1 AND y < 3{
 		set err to 8.
 		set A to .1.
 		set y to y+1.
 		}.
 	if y > 1 {
 		set error to 1-(err*verticalspeed).
 		set C to mass*A.
 		set B to ((W^2)+(C^2))^.5.
 		set x to B/maxthrust.
 		if x > 1 {
 			set x to 1.
 			}.
 		set theta to arctan(W/C).
 		set theta to theta*error.
 		}.
 	print verticalspeed at (20,1).
 	print Vo at (20,2).
 	print theta at (20,4).
 	}.
 lock throttle to 0.
 clearscreen.
 // DONE!

 set e to (apoapsis-periapsis)/(apoapsis+periapsis).
 print "Eccentricity" at (0,0). print e at (20,0).
 set avg to (apoapsis+periapsis)/2-FINAL.
 set error to avg/FINAL*100.
 print "Error " + error + "%" at (0,1).
 print "Craft is now in Parking Orbit. Begin Phase I" at (0,3).
 wait 5.
 if stage:liquidfuel > 0 AND stage:liquidfuel < 1000 {
 	stage.
 	wait 1.
 	stage.
 	}

Note: This file is publicly editable and might contain malicious code.
Please exercise caution when using.
PhaseI.txt view
[]




clearscreen.
set thrust to 0.
lock steering to prograde.
lock throttle to thrust.
// Calculate the required Delta-V.
// The Insertion burn distance and Final Apoapsis for this burn were calculated on MatLab.
// The Calculated Final Periapsis on the Mun is around 50km.
set Ra to 1.2*(10^7).
set Rp to (apoapsis+periapsis)/2+600000.
set GM to 3.5316*(10^12).
set e to (Ra-Rp)/(Ra+Rp).
set a to (Ra+Rp)/2.
set h to (GM*a*(1-(e^2)))^.5.
set Vp to h/Rp.
set Va to h/Ra.
set Vcir to (GM/Rp)^.5.
set dV to Vp-Vcir.
set target to "Directly Below Kerbin".
set LAUNCH to 1.229146628119515*(10^7).
set x to 0.
set y to 0.
wait 10.
set diff to 1.
set warp to 4.
print "Warp to Insertion Burn point".
// Warp until directly under the Mun. This is to make sure we are at least past the insertion point.
until diff > 0 {
	set D1 to target:distance.
	wait .1.
	set D2 to target:distance.
	set diff2 to LAUNCH-D2.
	set diff to D1-D2.
	}
print "Relative Speed" at (0,1).
print "Diff. from Insertion Burn" at (0,2).
until x = 1 {
	set D1 to target:distance.
	wait .1.
	set D2 to target:distance.
	set diff2 to LAUNCH-D2.
	set diff to D1-D2.
	print diff + "      " at (26,1).
	print diff2 + "     " at (26,2).
	if diff > 0 AND diff2 < (-200000) AND y = 0{
		set warp to 3.
		set y to 1.
		}
	if diff > 0 AND diff2 > (-100000) AND y = 1{
		set warp to 1.
		set y to 2.
		}
	if diff > 0 AND diff2 > (-30000) AND y = 2{
		set warp to 0.
		set y to 3.
		print "Preparing for Burn" at (0,3).
		}
	if diff2 > (-2000) AND y = 3 {
		set x to 1.
		}
	}
clearscreen.
print "Burn to Mun Intercept" at (0,0).
print "Orbital Speed" at (0,1).
print "Desired Speed" at (0,2).
print "Current Apoapsis" at (0,3).
print "Desired Apoapsis" at (0,4).
print Vp at (20,2).
print Ra-600000 at (20,4).
set y to .5.
until Vp-V < 0 {
	set thrust to x.
	set vec to velocity:orbit.
	set Vx to vec:x.
	set Vy to vec:y.
	set Vz to vec:z.
	set V to ((Vx^2)+(Vy^2)+(Vz^2))^.5.
	if stage:liquidfuel = 0 {
		stage.
		}
	if (Vp-V) > 100  AND y < 1{
		set x to 1.
		set y to y+1.
		}
	if (Vp-V) < 150  AND y < 2{
		set x to (mass*10)/maxthrust.
		set y to y+1.
		}
	if (Vp-V) < 20 AND y < 3{
		set x to (mass*1)/maxthrust.
		set y to y+1.
		}
	if (Vp-V) < 2 AND y < 4{
		set x to (mass*.1)/maxthrust.
		set y to y+1.
		}
	if apoapsis > (Ra-600000) {
		break.
		}
	print V at (20,1).
	print apoapsis at (20,3).
	}.
set thrust to 0.
clearscreen.
print "Warp to SOI Intercept".
set x to 0.
until x = 1 {
	if body = "Kerbin" {
		set warp to 5.
		}
	if body = "Mun" {
		set warp to 0.
		set x to 1.
		}
	}
set warp to 0.
print "End of Phase I".
wait 3.

Note: This file is publicly editable and might contain malicious code.
Please exercise caution when using.
PhaseII.txt view
[]




clearscreen.
set SOI to 2429559.1.
print "Warp to Mun Periapsis".
set warp to 5.
wait until eta:periapsis < 2000.
set warp to 4.
wait until eta:periapsis < 500.
set warp to 3.
wait until eta:periapsis < 50.
set warp to 0.
lock steering to retrograde.
clearscreen.
print "Burn for Mun Capture".
wait until eta:periapsis < 1.
lock throttle to 1.
wait until apoapsis > 0.
wait until apoapsis < .5*SOI.
lock throttle to 0.
set thrust to 0.
lock throttle to thrust.
// Calculate Delta-V to circularize orbit
set GM to 6.5138398*(10^10).
set Rp to periapsis+200000.
set vcir to (GM/Rp)^.5.
set Ra to apoapsis+200000.
set a to (Ra+Rp)/2.
set e to (Ra-Rp)/(Ra+Rp).
set h to (GM*a*(1-(e^2)))^.5.
set Vp to h/Rp.
set ar to (Va^2)/Rp.
set g to GM/(Rp)^2.
set W to mass*(g-ar).
set theta to arcsin(W/maxthrust).
wait 5.
// I do two seperate burns to help make the burns more efficient
// It is more efficient to burn at Periapsis
// Warp!
print "Warp to Periapsis".
print theta.
set warp to 5.
wait until eta:periapsis < 2000.
set warp to 4.
wait until eta:periapsis < 500.
set warp to 3.
wait until eta:periapsis < 50.
set warp to 0.
lock steering to heading 270 by theta.
clearscreen.

// Waiting on periapsis arrival.
print "Vertical Speed" at (0,1).
until verticalspeed > 0 {
	print verticalspeed at (20,1).
	print "T-minus " + eta:periapsis + " to periapsis" at (0,0).
	}.
clearscreen.

// Burn to circularize, theta is used to maintain the apogee infront of the craft
print "Burn to Circularize Orbit" at (0,0).
print "Vertical Speed" at (0,1).
print "Orbital Speed" at (0,2).
print "Vcir" at (0,3).
print vcir at (20,3).
print "Theta" at (0,4).
print theta at (20,4).
set y to .5.
set Vo to 1000.
set z to 0.
set x to 1.
until Vo-vcir < .001 {
	set thrust to x.
	set vorbit to velocity:orbit.
	set Vox to vorbit:x.
	set Voy to vorbit:y.
	set Voz to vorbit:z.
	set Vo to ((Vox^2)+(Voy^2)+(Voz^2))^.5.
	set ar to (Vo^2)/r.
	set W to mass*(g-ar).
	
	if y = .5 {
		set err to .75.
		set error to 1-(err*verticalspeed).
		set theta to arcsin(W/maxthrust).
		set theta to theta*error.
		}.
	if stage:liquidfuel = 0 AND z < 1{
		stage.
		set z to 1.5.
		}.
	if (Vo-vcir) < 100  AND y < 1{
		set err to 4.
		set A to 10.
		set y to y+1.
		}.
	if (Vo-vcir) < 10 AND y < 2{
		set err to 5.
		set A to 1.
		set y to y+1.
		}.
	if (Vo-vcir) < 1 AND y < 3{
		set err to 6.
		set A to .1.
		set y to y+1.
		}.
	if y > 1 {
		set error to 1-(err*verticalspeed).
		set C to mass*A.
		set B to ((W^2)+(C^2))^.5.
		set x to B/maxthrust.
		if x > 1 {
			set x to 1.
			}.
		set theta to arctan(W/C).
		set theta to theta*error.
		}.
	print verticalspeed at (20,1).
	print Vo at (20,2).
	print theta at (20,4).
	}.
lock throttle to 0.
clearscreen.
// DONE!

set e to (apoapsis-periapsis)/(apoapsis+periapsis).
print "Eccentricity" at (0,0). print e at (20,0).
set avg to (apoapsis+periapsis)/2-FINAL.
set error to avg/FINAL*100.
print "Error " + error + "%" at (0,1).
print "Craft is now in stable circular orbit around Mun" at (0,3).
print "This ends Phase II, on to Phase III" at (0,4). 
wait 10.

Note: This file is publicly editable and might contain malicious code.
Please exercise caution when using.
PhaseIII.txt view
[]




clearscreen.
print "Destroying Kinetic Energy".
lock steering to retrograde.
set thrust to 0.
lock throttle to thrust.
wait 5.
set Vo to 100.
until Vo < 2 {
	set thrust to 1.
	set vorbit to velocity:orbit.
	set Vox to vorbit:x.
	set Voy to vorbit:y.
	set Voz to vorbit:z.
	set Vo to ((Vox^2)+(Voy^2)+(Voz^2))^.5.
	}
set thrust to 0.
lock steering to up.
set max to 500.
set x to 0.
set GM to 6.5138398*(10^10).
clearscreen.
print "Decending" at (0,0).
wait 5.
set warp to 2. 
wait until alt:radar < 15000.
set warp to 0.
print "Radar Altitude" at (0,1).
until alt:radar < 10 {
	if alt:radar < 10000 AND x = 0 {
		set max to 250.
		set x to 1.
		}
	if alt:radar < 5000 AND x = 1 {
		set max to 100.
		set x to 2.
		}
	if alt:radar < 2500 AND x = 2 {
		set max to 50.
		set x to 3.
		}
	if alt:radar < 500 AND x = 3 {
		set max to 25.
		set x to 4.
		toggle AG3.
		print "Brace for Impact" at (0,1).
		}
	if alt:radar < 100 AND x = 4 {
		set max to 2.5.
		set x to 5.
		}
	set r to altitude+200000.
	set g to GM/(r)^2.
	set Vdown to (-1)*verticalspeed.
	set err to 1.	
	set error to err*(Vdown-max).
	if max > Vdown {
		set thrust to 0.
		}
	if max < Vdown {
		set thrust to error*((mass*g)/maxthrust).
		}
	print alt:radar at (20,3).
	if Vdown < 0 {
	break.
	}
	}
set thrust to .9*((mass*g)/maxthrust).
wait until verticalspeed > 0.
set thrust to 0.
lock steering to up.
wait 10.
clearscreen.
print "Touchdown!" at (0,0).
print "This ends Phase III, Next is Phase IV" at (0,1).
wait 3.

Note: This file is publicly editable and might contain malicious code.
Please exercise caution when using.
PhaseIV.txt view
[]




clearscreen.
print "Begin Orbital Ascent".
set FINAL to 100000.
lock steering to up.
lock throttle to thrust.
wait 1. set thrust to 1.
wait 1.
lock steering to up + R(0,-89,0).
toggle AG3.

set x to 0.
until apoapsis > FINAL {
	if apoapsis > .9*FINAL AND x = 0{
		set thrust to (10*mass)/maxthrust.
		set x to 1.
		}.
	if apoapsis >.99*FINAL AND x = 1 {
		set thrust to mass/maxthrust.
		}.
	if apoapsis > FINAL {
		set thrust to 0.
		}.
	}.
set thrust to 0.

//Calculate circular velocity at apoapsis altitude
set x to 1.
set GM to 6.5138398*(10^10).
set r to apoapsis+200000.
set vcir to (GM/r)^.5.
set v to 0.
set per to periapsis+200000.
set a to (r+per)/2.
set e to (r-per)/(r+per).
set h to (GM*a*(1-(e^2)))^.5.
set Va to h/r.
set ar to (Va^2)/r.
set g to GM/(r)^2.
set W to mass*(g-ar).
set theta to arcsin(W/maxthrust).
wait 2.

// Warp!
print "Warp to Apogee".
print theta.
set warp to 4.
wait until eta:apoapsis < 1000.
set warp to 3.
wait until eta:apoapsis < 50.
set warp to 0.
lock steering to heading 90 by theta.
clearscreen.

// Waiting on apoapsis arrival.
print "Vertical Speed" at (0,1).
until verticalspeed < 0 {
	print verticalspeed at (20,1).
	print "T-minus " + eta:apoapsis + " to Apoapsis" at (0,0).
	}.
clearscreen.

// Burn to circularize, theta is used to maintain the apogee infront of the craft
print "Burn to Circularize Orbit" at (0,0).
print "Vertical Speed" at (0,1).
print "Orbital Speed" at (0,2).
print "Vcir" at (0,3).
print vcir at (20,3).
print "Theta" at (0,4).
print theta at (20,4).
set y to .5.
set Vo to 0.
set z to 0.
set x to 1.
until vcir-Vo < .001 {
	set thrust to x.
	set vorbit to velocity:orbit.
	set Vox to vorbit:x.
	set Voy to vorbit:y.
	set Voz to vorbit:z.
	set Vo to ((Vox^2)+(Voy^2)+(Voz^2))^.5.
	set ar to (Vo^2)/r.
	set W to mass*(g-ar).
	
	if y = .5 {
		set err to .75.
		set error to 1-(err*verticalspeed).
		set theta to arcsin(W/maxthrust).
		set theta to theta*error.
		}.
	if stage:liquidfuel = 0 AND z < 1{
		stage.
		set z to 1.5.
		}.
	if (Vcir-Vo) < 100  AND y < 1{
		set err to 4.
		set A to 10.
		set y to y+1.
		}.
	if (Vcir-Vo) < 10 AND y < 2{
		set err to 5.
		set A to 1.
		set y to y+1.
		}.
	if (Vcir-Vo) < 1 AND y < 3{
		set err to 7.
		set A to .1.
		set y to y+1.
		}.
	if y > 1 {
		set error to 1-(err*verticalspeed).
		set C to mass*A.
		set B to ((W^2)+(C^2))^.5.
		set x to B/maxthrust.
		if x > 1 {
			set x to 1.
			}.
		set theta to arctan(W/C).
		set theta to theta*error.
		}.
	print verticalspeed at (20,1).
	print Vo at (20,2).
	print theta at (20,4).
	}.
lock throttle to 0.
clearscreen.
// DONE!

set e to (apoapsis-periapsis)/(apoapsis+periapsis).
print "Eccentricity" at (0,0). print e at (20,0).
set avg to (apoapsis+periapsis)/2-FINAL.
set error to avg/FINAL*100.
print "Error " + error + "%" at (0,1).
print "Craft is now in Parking Orbit. Begin Phase V" at (0,3).
wait 5.

Note: This file is publicly editable and might contain malicious code.
Please exercise caution when using.
PhaseV.txt view
[]




clearscreen.
// Calculation of the Launch Angle (Beta) and Delta-V of Hyperbolic Escape Trajectory were done on MatLab
// Final periapsis on Kerbin will be calculated to roughly 30,000m but it normally ends up being much lower.
set LAUNCH to 21.877991837556678.
set dV to 2.859013122877032*(10^2).
set vorbit to velocity:orbit.
set vx to vorbit:x.
set vy to vorbit:y.
set vz to vorbit:z.
set Vo to ((vx^2)+(vy^2)+(vz^2))^.5.
set Vfinal to Vo + dV.
set thrust to 0.
lock throttle to thrust.
lock steering to heading 90 by 0.
wait 5.
// Warp!
clearscreen.
print "Warp to Escape Burn Point".
set warp to 4.
wait until longitude < 0.
wait until longitude > 0.
set warp to 3.
wait until longitude > 15.
set warp to 2.
wait until longitude > 18.
set warp to 0.
wait until longitude > LAUNCH.


print "Burn for Mun Escape" at (0,0).
print "Orbital Speed" at (0,1).
print "Desired Speed" at (0,2).
print Vfinal at (20,2).
set y to .5.
set V to 0.
until Vfinal-V < 0 {
	set thrust to x.
	set vec to velocity:orbit.
	set Vx to vec:x.
	set Vy to vec:y.
	set Vz to vec:z.
	set V to ((Vx^2)+(Vy^2)+(Vz^2))^.5.
	if stage:liquidfuel = 0 {
		stage.
		}
	if (Vfinal-V) > 100  AND y < 1{
		set x to 1.
		set y to y+1.
		}
	if (Vfinal-V) < 150  AND y < 2{
		set x to (mass*10)/maxthrust.
		set y to y+1.
		}
	if (Vfinal-V) < 20 AND y < 3{
		set x to (mass*1)/maxthrust.
		set y to y+1.
		}
	if (Vfinal-V) < 2 AND y < 4{
		set x to (mass*.1)/maxthrust.
		set y to y+1.
		}
	print V at (20,1).
	}.
set thrust to 0.
clearscreen.
print "Warp to SOI Intercept".
set x to 0.
until x = 1 {
	if body = "Mun" {
		set warp to 5.
		}
	if body = "Kerbin" {
		set warp to 0.
		set x to 1.
		}
	}
set warp to 0.
print "End of Phase V".
wait 3.

Note: This file is publicly editable and might contain malicious code.
Please exercise caution when using.
Reentry.txt view
[]




clearscreen.
print "Now finally to Warp to Kerbin Atmosphere and deploy the parachute!".
lock steering to retrograde.
wait 5.
set warp to 5.
wait until alt:radar < 5000.
stage.
wait 1.
stage.
wait until verticalspeed > 0.
clearscreen.
print "Landed! (Or Splashed!) Program terminated, thanks for flying!".


Note: This file is publicly editable and might contain malicious code.
Please exercise caution when using.
Orbiter III.craft view
[]


Downloads from Dropbox provided by the script author. See also Reddit

Advertisement