Initial cleanup of ascent logic, not tested
This commit is contained in:
+38
@@ -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.
|
||||
}
|
||||
Reference in New Issue
Block a user