forked from JonnyOThan/tpksp-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecute_node_old.ks
More file actions
60 lines (45 loc) · 1.34 KB
/
execute_node_old.ks
File metadata and controls
60 lines (45 loc) · 1.34 KB
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
parameter tail_factor is 0.2.
run once "util/logging".
run once "util/util".
log_message("=== execute_node ===").
if not sas or sasmode <> "maneuver" {
sas off.
lock steering to nextnode:deltav.
}
local burn_duration to get_burn_duration(nextnode:deltav:mag).
wait until vang(ship:facing:vector, nextnode:deltav) < 0.5.
warp_and_wait(nextnode:eta - burn_duration/2 - 60).
wait until vang(ship:facing:vector, nextnode:deltav) < 0.5.
local time_to_burn_start is nextnode:eta - burn_duration/2.
if (time_to_burn_start < -5) {
log_error("PASSED BURN START TIME!").
}
warp_and_wait(time_to_burn_start).
local initial_node_direction is nextnode:deltav.
if tail_factor > 0 {
function get_throttle {
local result is 0.
if (ship:maxthrust>0) {
set result to min(1, nextnode:deltav:mag / (tail_factor * ship:maxthrust / ship:mass)).
}
return result.
}
lock throttle to get_throttle().
} else {
lock throttle to 1.
}
until vang(initial_node_direction, nextnode:deltav) > 90 or nextnode:deltav:mag < 0.001 {
if ship:maxthrust = 0 {
log_message("stage expired during node execution; remaining dv: " + round(nextnode:deltav:mag, 1)).
stage_to_next_engine().
}
wait 0.
}
sas off.
lock steering to "kill".
lock throttle to 0.
wait 0.
unlock throttle.
wait 1.
remove nextnode.
wait 0.