diff --git a/boot/default.ks b/boot/default.ks index 47b7b6f..f5869d3 100755 --- a/boot/default.ks +++ b/boot/default.ks @@ -1,5 +1,6 @@ CLEARSCREEN. print "=================== BOOTING ===================". +wait until SHIP:UNPACKED. if HOMECONNECTION:ISCONNECTED { update_scripts(). diff --git a/launch.ks b/launch.ks index a3c976c..4395eb8 100755 --- a/launch.ks +++ b/launch.ks @@ -47,14 +47,16 @@ function launch { set NAVMODE to "SURFACE". lock STEERING to HEADING(launch_azimuth, 90). // roll to launch azimuth lock THROTTLE to 1.0. - STAGE. - // Enable auto-stage when the maximum engine thrust changes (i.e. some engines ran out of fuel) - on SHIP:MAXTHRUSTAT(0) { - when STAGE:READY then { - print "STAGING". - STAGE. - }. + + // LAUNCH + + // Can't use flameout or MAXTHRUSTAT on the initial staging, since the rocket may be held down by a launch tower + until STAGE:SOLIDFUEL + STAGE:LIQUIDFUEL <> 0 stage_when_ready(). + + // Auto-stage when any of the engines flameout or if there are no active engines (e.g. when we have an intermediate stage for decouplers before activating the next engine) + when any_flameout() or SHIP:MAXTHRUSTAT(0) = 0 then { + stage_when_ready(). return true. // preserve trigger } diff --git a/util.ks b/util.ks index b780fc9..1004eb2 100755 --- a/util.ks +++ b/util.ks @@ -11,6 +11,12 @@ function warp_for { } +function stage_when_ready { + wait until STAGE:READY. + print "STAGING". + STAGE. +} + function isp_sum { local sum is 0. @@ -22,6 +28,15 @@ function isp_sum { } +function any_flameout { + list ENGINES in engines_list. + for engine in engines_list { + if engine:FLAMEOUT return true. + } + return false. +} + + function round_towards_zero { parameter n.