kOS-scripts/lib/util.ks

39 lines
866 B
Plaintext
Raw Normal View History

@LAZYGLOBAL OFF.
2019-02-08 22:17:19 +01:00
function int {
//
// Truncate or round towards zero.
//
parameter n.
if n < 0 return ceiling(n).
return floor(n).
}
2019-02-08 22:17:19 +01:00
function atmosphere_exit_eta {
//
// Return the number of seconds until the vessel exists the atmosphere.
//
// The vdot gives us the magnitude of the orbital velocity vector in the UP direction because UP is a unit vector
2019-02-08 22:17:19 +01:00
return (BODY:atm:height - ALTITUDE) / vdot(velocity:orbit, UP:vector).
}
2019-02-10 15:33:50 +01:00
function list_remove {
//
// Remove given element from a list.
//
parameter lst.
parameter element.
local i is 0.
until lst:empty or i = lst:length {
if lst[i] = element {
lst:remove(i).
} else {
set i to i + 1. // dont increment if we deleted an element since this index now contains a new one
}
}
}