-
Notifications
You must be signed in to change notification settings - Fork 0
/
newlaunch.ks
296 lines (118 loc) · 3.45 KB
/
newlaunch.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
parameter orb.
clearscreen.
lock TTW to (maxthrust+0.1)/mass.
set mode to 2.
if ALT:RADAR < 50 { set mode to 1. }
when SHIP:periapsis > 70000 then { set mode to 4. }
when SHIP:ALTITUDE > 9000 then { set mode to 3. }
when (ETA:APOAPSIS > 90) and (apoapsis > orb) and (ETA:PERIAPSIS > ETA:APOAPSIS) then { set mode to 4. preserve.}
until mode = 0 {
if mode = 1 {
// launch
print "T-MINUS 10 seconds".
lock steerin to up.
wait 1.
print "T-MINUS 9 seconds".
lock throttle to 1.
wait 1.
print "T-MINUS 8 seconds".
wait 1.
print "T-MINUS 7 seco...".
stage.
wait 1.
print "......and here we GO, i guess".
wait 2.
clearscreen.
set mode to 2.
}
else if mode = 2 { // fly up to 9km
lock steering to heading(90,90).
}
else if mode = 3{
// gravity turn
set targetPitch to max( 8, 90 * (1 - ALT:RADAR / 70000)).
lock steering to heading (90, targetPitch).
if SHIP:APOAPSIS > orb{
set mode to 4.
}
if TTW > 20{
lock throttle to 20*mass/(maxthrust+0.1).
}
}
else if mode = 4{
// coast to orbit
if (ship:maxthrust = 0) {
unlock steering.
}
lock throttle to 0.
if (SHIP:ALTITUDE > 70000) and (ETA:APOAPSIS > 70) and (VERTICALSPEED > 0) {
if WARP = 0 {
wait 1.
SET WARP TO 3.
}
}
else if ETA:APOAPSIS < 70 {
SET WARP to 0.
lock steering to heading(90,0).
wait 2.
set mode to 5.
}
if (periapsis > 70000) and mode = 4{
if WARP = 0 {
wait 1.
SET WARP TO 3.
}
}
}
else if mode = 5 {
if ETA:APOAPSIS < 15 or VERTICALSPEED < 0 {
lock throttle to 1.
}
if (eta:periapsis - eta:apoapsis < 0) {
lock steering to heading(90, 30).
} else {
lock steering to heading(90, 0).
}
if ship:periapsis > orb {
lock throttle to 0.
set mode to 6.
}
}
else if mode = 6 {
lock throttle to 0.
panels on. //Deploy solar panels
lights on.
unlock steering.
//set mode to 0.
print "WELCOME TO A STABE SPACE ORBIT!".
wait 2.
}
// this is the staging code to work with all rockets //
if stage:number > 0 {
if maxthrust = 0 {
stage.
}
SET numOut to 0.
LIST ENGINES IN engines.
FOR eng IN engines
{
IF eng:FLAMEOUT
{
SET numOut TO numOut + 1.
}
}
if numOut > 0 { stage. }.
}
// HERE is the code for the control pannel //
print "LAUNCH PLAN STAGE " + mode at (0, 0).
print " " at (0, 1).
print "Periapsis height: " + round(periapsis, 2) + " m" at (0, 2).
print " Apoapsis height: " + round(apoapsis, 2) + " m" at (0, 3).
print " ETA to Apoapsis: " + round(ETA:APOAPSIS) + " s" at (0, 4).
print " Orbital speed: " + round(velocity:orbit:MAG, 2)+ " m/s" at (0, 5).
print " altitude: " + round(altitude, 2) + " m" at (0, 6).
print "thrust to weight: " + round((throttle*maxthrust)/mass) at (0, 7).
print " " at (0, 8).
print "Currently on Stage: " + stage:number at (0, 9).
wait 0.2.
}