Skip to content

Instantly share code, notes, and snippets.

/ALR

Created January 15, 2017 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/43094dd17d4e62d87a68cd460ab2079a to your computer and use it in GitHub Desktop.
Save anonymous/43094dd17d4e62d87a68cd460ab2079a to your computer and use it in GitHub Desktop.
Auto-Landing Rocket
print "INITIALIZE SYSTEMS".
rcs on.
sas on.
set IT to 0.65.
set LT to 0.25.
set SFL to 0.40.
set DVS to 100.
wait 1.0.
print "3...".
wait 1.0.
print "2...".
wait 1.0.
print "1...".
wait 1.0.
print "FLY TO THE SKY".
stage.
lock throttle to IT.
until false {
set totalFuelAmount to 0.0.
set totalFuelCapacity to 0.0.
list resources in reslist.
for res in reslist {
if res:name = "LIQUIDFUEL" {
set totalFuelAmount to totalFuelAmount + res:amount.
set totalFuelCapacity to totalFuelCapacity + res:capacity.
}
}
if totalFuelAmount / totalFuelCapacity < SFL { break. }
wait 0.001.
}
print "WAIT FOR DEPLOYMENT...".
lock throttle to 0.0.
until ship:verticalspeed < DVS {
wait 0.001.
}
print "DEPLOY".
stage.
print "WAIT FOR LANDING".
until alt:radar < 20000.0 {
wait 0.001.
}
print "LANDING MANOUVER".
set VS to -300.0.
until alt:radar < 1000.0 {
if alt:radar > 10000.0 {
set VS to -200.0.
}
else if alt:radar > 5000.0 {
set VS to -100.0.
}
else if alt:radar > 2000.0 {
set VS to -50.0.
}
if ship:verticalspeed > VS {
lock throttle to 0.0.
}
else {
lock throttle to LT.
}
wait 0.001.
}
print "PARACHUTES".
lock throttle to 0.0.
gear on.
stage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment