-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmarsland.ks
58 lines (46 loc) · 1.51 KB
/
marsland.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
@lazyglobal off.
//parameter myMaxThrust.
local myMaxThrust to 180.16.
function trueAlt {
if abs(altitude) < 0.05 or abs(altitude - alt:radar) / altitude > 0.05 {
return alt:radar.
} else {
return altitude - ship:geoposition:terrainheight.
}
}
local gSurf to body:mu / (body:radius ^ 2).
sas off.
gear off.
when (trueAlt() < 15000) then set warp to 0.
wait until trueAlt() < 4000.
clearscreen.
print "trueAlt :" at (2, 10).
print "tgtVel :" at (2, 11).
print "tgtAccel :" at (2, 12).
print "gSurf :" at (2, 13).
print "throt :" at (2, 14).
local lock tgtVel to -trueAlt() / 20 - 2.
local lock maxEngineAccel to myMaxThrust / mass.
lock steering to lookdirup(-ship:obt:velocity:surface, ship:facing:topvector).
local throt to 0.
lock throttle to throt.
when (ship:obt:velocity:surface:mag < 150) then stage.
when (ship:obt:velocity:surface:mag < 50) then {
ag2 on. // cut parachutes
steeringmanager:resetpids(). // forget about accumulated error from parachutes
}
when (trueAlt() < 500) then gear on.
when (ship:obt:velocity:surface:mag < 5) then lock steering to lookdirup(up:vector, ship:facing:topvector).
// this might be helping or it might not
set steeringmanager:maxstoppingtime to 10.
until status = "Landed" {
local tgtAccel to tgtVel + ship:obt:velocity:surface:mag.
set throt to (tgtAccel + gSurf) / maxEngineAccel.
print trueAlt() at (15, 10).
print tgtVel at (15, 11).
print tgtAccel at (15, 12).
print gSurf at (15, 13).
print throt at (15, 14).
wait 0.05.
}
set throt to 0.