Improve auto-staging on launch to work with more ships.

Wait until ship fully loaded (unpacked) before commencing boot procedure.
This commit is contained in:
Casper V. Kristensen 2018-07-26 23:47:23 +02:00
parent 08246d4d83
commit 95c68aa15f
Signed by: caspervk
GPG key ID: B1156723DB3BDDA8
3 changed files with 25 additions and 7 deletions

View file

@ -1,5 +1,6 @@
CLEARSCREEN.
print "=================== BOOTING ===================".
wait until SHIP:UNPACKED.
if HOMECONNECTION:ISCONNECTED {
update_scripts().

View file

@ -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
}

15
util.ks
View file

@ -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.