From fc688799fefdc7dd0d7e637664ebd47be870579a Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Sun, 10 Feb 2019 15:33:50 +0100 Subject: [PATCH] Small QoL and readability. --- boot/default.ks | 4 ++-- launch.ks | 2 ++ lib/rendezvous.ks | 14 ++++++++++++++ lib/util.ks | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 lib/rendezvous.ks diff --git a/boot/default.ks b/boot/default.ks index 5bea42b..d595288 100644 --- a/boot/default.ks +++ b/boot/default.ks @@ -4,8 +4,8 @@ clearscreen. clearguis(). clearvecdraws(). -set TERMINAL:width to 50. -set TERMINAL:height to 30. +set TERMINAL:width to max(TERMINAL:width, 50). +set TERMINAL:height to max(TERMINAL:height, 30). CORE:doaction("Open Terminal", true). print "==================== BOOTING =====================". diff --git a/launch.ks b/launch.ks index 067c56e..a847e57 100644 --- a/launch.ks +++ b/launch.ks @@ -9,7 +9,9 @@ run once "lib/warp". function launch { + // // Launch to orbit of provided altitude and inclination. + // parameter target_orbit_altitude is 100_000. // meters parameter target_orbit_inclination is 0. // 0-180 degrees parameter pitchover_tilt is 20. // how many degrees to tilt at pitchover maneuver diff --git a/lib/rendezvous.ks b/lib/rendezvous.ks new file mode 100644 index 0000000..8c6cf4a --- /dev/null +++ b/lib/rendezvous.ks @@ -0,0 +1,14 @@ +@LAZYGLOBAL off. + +run once "lib/node". + + +function kill_relative_velocity { + parameter target is TARGET. + parameter tolerance is 0.1. + + local relative_velocity is target:velocity:orbit - SHIP:velocity:orbit. + if relative_velocity:mag > tolerance { + execute_burn(relative_velocity). + } +} diff --git a/lib/util.ks b/lib/util.ks index 5ab9c35..60621e0 100644 --- a/lib/util.ks +++ b/lib/util.ks @@ -18,3 +18,21 @@ function atmosphere_exit_eta { // The vdot gives us the magnitude of the orbital velocity vector in the UP direction because UP is a unit vector return (BODY:atm:height - ALTITUDE) / vdot(velocity:orbit, UP:vector). } + + +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 + } + } +}