2018-07-27 17:23:38 +02:00
|
|
|
@LAZYGLOBAL OFF.
|
|
|
|
|
|
|
|
function any_flameout {
|
|
|
|
//
|
|
|
|
// Return true if any of our engines are starved for fuel. Primarily used to determine the need for staging.
|
|
|
|
//
|
2018-08-05 19:40:16 +02:00
|
|
|
local engines_list is LIST().
|
2018-07-27 17:23:38 +02:00
|
|
|
list ENGINES in engines_list.
|
|
|
|
for engine in engines_list {
|
2018-08-05 19:40:16 +02:00
|
|
|
if engine:ignition and engine:flameout {
|
2018-07-27 17:23:38 +02:00
|
|
|
return true.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function should_stage {
|
|
|
|
//
|
|
|
|
// Return true if the rocket needs to stage.
|
|
|
|
//
|
2018-08-05 19:40:16 +02:00
|
|
|
return STATUS = "PRELAUNCH" // e.g. still attached to launch tower
|
2019-02-08 18:45:13 +01:00
|
|
|
or any_flameout() // any engine starved for fuel
|
|
|
|
or SHIP:maxthrustat(0) = 0. // no active engines (e.g. when we have an intermediate stage for decouplers before activating the next engine)
|
2018-07-27 17:23:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function stage_when_ready {
|
|
|
|
//
|
|
|
|
// Stage when ready. Blocks until staging has been initiated.
|
|
|
|
//
|
2018-08-05 19:40:16 +02:00
|
|
|
wait until STAGE:ready.
|
2018-07-27 17:23:38 +02:00
|
|
|
print "STAGING".
|
|
|
|
STAGE.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function isp_sum {
|
|
|
|
//
|
|
|
|
// Return the sum of vacuum ISP for enabled engines.
|
|
|
|
//
|
|
|
|
local sum is 0.
|
2018-08-05 19:40:16 +02:00
|
|
|
local engines_list is LIST().
|
2018-07-27 17:23:38 +02:00
|
|
|
list ENGINES in engines_list.
|
|
|
|
for engine in engines_list {
|
2018-08-05 19:40:16 +02:00
|
|
|
if engine:ignition {
|
|
|
|
set sum to sum + engine:vacuumisp.
|
2018-07-27 17:23:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return sum.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-08 22:16:20 +01:00
|
|
|
function deploy_fairings {
|
|
|
|
print "Deploying fairings".
|
2019-03-01 23:22:17 +01:00
|
|
|
local fairings is SHIP:modulesnamed("ModuleProceduralFairing").
|
|
|
|
for fairing in fairings {
|
|
|
|
fairing:doaction("deploy", true).
|
|
|
|
}
|
|
|
|
if not fairings:empty {
|
|
|
|
wait 3. // wait for fairings to clear the vessel
|
2019-02-08 22:16:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function extend_antennas {
|
|
|
|
print "Extending antennas".
|
|
|
|
for module in SHIP:modulesnamed("ModuleDeployableAntenna") {
|
|
|
|
module:doaction("extend antenna", true).
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-27 17:23:38 +02:00
|
|
|
function unlock_control {
|
|
|
|
//
|
|
|
|
// Ensure that the throttle is 0 and that the player is not locked out of control.
|
|
|
|
//
|
2018-08-05 19:40:16 +02:00
|
|
|
set SHIP:control:pilotmainthrottle to 0.
|
|
|
|
set SHIP:control:neutralize to true.
|
2018-07-27 17:23:38 +02:00
|
|
|
unlock STEERING.
|
|
|
|
unlock THROTTLE.
|
|
|
|
}
|