Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print "hello script".
- global all_engines to LIST().
- list ENGINES in all_engines.
- set staging to false.
- set running to false.
- function notify {
- parameter reached.
- parameter condition.
- if (condition) {
- print "Reached " + reached.
- }
- return condition.
- }
- function out_of_atmosphere {
- return notify("out of atmosphere", ship:altitude > 55000).
- }
- function periapsis_goal {
- return notify("periapsis target", ship:periapsis > target_periapsis).
- }
- function apoapsis_goal {
- return notify("apoapsis target", ship:apoapsis > target_apoapsis).
- }
- function check_engines_flameout {
- for eng in all_engines {
- if eng:stage >= stage:number and not eng:flameout {
- return false.
- }
- }
- return true.
- }
- function ideal_throttle {
- if apoapsis_goal() and not periapsis_goal() and eta:apoapsis < 20 {
- return 0.75.
- } else if apoapsis_goal() and not periapsis_goal() and eta:apoapsis >= 20 {
- return 0.
- } else if not out_of_atmosphere() {
- return 1.
- } else if not apoapsis_goal() {
- return 0.75.
- } else {
- return 0.
- }
- }
- function ideal_steering {
- if staging {
- return facing.
- } else if apoapsis_goal() {
- return heading(90, 0, -90).
- } else if ship:altitude < 55000 or not apoapsis_goal() {
- set ship_velocity_factor to ship:velocity:surface:mag / 200.
- set angle to max(0, 90 - ship_velocity_factor * 10).
- return heading(90, angle, -90).
- } else {
- return heading(90, 0, -90).
- }
- }
- function launch_ship {
- print "Running".
- set running to true.
- until periapsis_goal() and apoapsis_goal() {
- if check_engines_flameout() {
- print "Staging !".
- set staging to true.
- wait 0.5.
- STAGE.
- set staging to false.
- }
- set throttle to ideal_throttle().
- set steering to ideal_steering().
- wait 0.2.
- }
- set running to false.
- }
- set target_apoapsis to 75000.
- set apoapsis_offset to 5000.
- set real_target_apoapsis to target_apoapsis - apoapsis_offset.
- set target_periapsis to target_apoapsis - (target_apoapsis * 0.05).
- // main
- print "main".
- rcs on.
- stage.
- print "go !".
- when ship:apoapsis < target_apoapsis and not running then {
- launch_ship().
- preserve.
- }
- wait until apoapsis_goal() and periapsis_goal().
- set throttle to 0.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement