Initial cleanup of ascent logic, not tested

This commit is contained in:
2026-05-20 10:54:07 -07:00
parent 8aec6aa8a4
commit 6dd14708bc
5 changed files with 183 additions and 97 deletions
+38
View File
@@ -0,0 +1,38 @@
declare function basicStaging {
when ship:maxThrust = 0 then {
print "Staging".
stage.
preserve.
}.
}
function calcBurnTime {
parameter dvNeeded.
local totalTime to 0.
local dvRemaining to dvNeeded.
local stageNum to ship:stagenum.
until dvRemaining <= 0 or stageNum < 0 {
local stageDv to ship:stagedeltav(stageNum):current.
local stageTime to ship:stagedeltav(stageNum):duration.
if stageDv <= 0 {
set stageNum to stageNum - 1.
} else if stageDv >= dvRemaining {
set totalTime to totalTime + stageTime * (dvRemaining / stageDv).
set dvRemaining to 0.
} else {
set totalTime to totalTime + stageTime.
set dvRemaining to dvRemaining - stageDv.
set stageNum to stageNum - 1.
}
}
if dvRemaining > 0 {
print "WARNING: Insufficient dV. Short by " + round(dvRemaining, 1) + " m/s.".
}
return totalTime.
}