-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunKerbalXScript.ks
86 lines (76 loc) · 2.07 KB
/
runKerbalXScript.ks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
global stagingRocket TO FALSE.
function main {
launchStart().
print "Lift Off!".
ascentGuidance().
until apoapsis > 95000 {
PRINT "Monitoring Ascent Staging...".
ascentStaging().
}
PRINT "Circularization burn commencing.".
circularizationBurn().
PRINT "Circularization burn ended.".
// spacecraftConfigManeuver().
// munarTransferBurn().
// munarOrbitalBurn().
}
function launchStart {
sas OFF.
print "Guidance Internal".
lock throttle to 1.
for i in range(0,5){
print "Countdown: " + (5 - i).
wait 1.
}
print "All systems go.".
stageRocket("Launch").
}
function stageRocket {
parameter stageName.
wait until stage:ready.
SET stagingRocket TO TRUE.
PRINT "Staging " + stageName + "...".
stage.
SET stagingRocket TO FALSE.
}
function ascentGuidance {
PRINT "Ascent Guidance Operational...".
lock targetPitch to 88.963 - 1.03287 * alt:radar^0.409511.
lock steering to heading(90, targetPitch).
}
function ascentStaging {
if not(defined oldThrust) {
global oldThrust is ship:availablethrust.
}
if ship:availablethrust < (oldThrust - 10) {
until false {
stageRocket("Rocket"). wait 1.
// abortSystemMonitor().
if ship:availableThrust > 0 {
break.
}
}
global oldThrust is ship:availablethrust.
}
}
function circularizationBurn {
// wait until time until apoapsis is 1/2 probable burn for circularization
lock steering to PROGRADE.
lock THROTTLE to 0.
// burn, and stage, until periapsis is 90km
PRINT "Wait until apoapsis < 5s.".
WAIT UNTIl ETA:APOAPSIS < 5.
until periapsis > 90000 {
PRINT "in the until periapsis > 90km".
lock THROTTLE to 1.
if ship:availableThrust = 0 {
stageRocket("Rocket"). wait 1.
// abortSystemMonitor().
if ship:availableThrust > 0 {
break.
}
}
}
LOCK THROTTLE TO 0.
}
main().