From 6b5b88286bbbda20554ebd7b3c9160efa4a81424 Mon Sep 17 00:00:00 2001 From: KenwoodFox Date: Sun, 11 Apr 2021 22:22:06 -0400 Subject: [PATCH] This nearly mostly works! --- RadarrSeries/boot.ks | 35 +++++++++++++++++++++++++++++++++++ boot/radarr_boot.ks | 2 ++ boot/tagBoot.ks | 18 ++++++++++++++++++ libraries/abort.ks | 3 +++ 4 files changed, 58 insertions(+) create mode 100644 RadarrSeries/boot.ks create mode 100644 boot/tagBoot.ks diff --git a/RadarrSeries/boot.ks b/RadarrSeries/boot.ks new file mode 100644 index 0000000..d9145a0 --- /dev/null +++ b/RadarrSeries/boot.ks @@ -0,0 +1,35 @@ +// Written based off CheersKevin's youtube series +// On programming in KOS + +// This script is the boot script for the Radarr +// series of surface scanning probes. + + +// This method prints in big letters something on the screen. +FUNCTION NOTIFY { + PARAMETER message. + PARAMETER duration IS 5. + PARAMETER color IS WHITE. + + HUDTEXT("kOS: " + message, duration, 2, 50, color, false). + PRINT message. +} + +NOTIFY("Boot sequence complete, prepare to load and compile the flight scripts."). + +IF true { // Set this to false to avoid compiling ascent code. + COMPILE "0:/RadarrSeries/radarr_kerbin.ks" TO "1:/ascent.ksm". // Compile the flight code into a ksm object. +} ELSE { + COPYPATH("0:/RadarrSeries/radarr_kerbin.ks", "1:/ascent.ks"). // Copy over our launch script from the archive at ksc +} + +// I changed this! + +NOTIFY("Program compiled and ready to run."). + +IF alt:radar < 100 { // If our radar alt is lower than 10 + WAIT 5. + RUN ascent.ks. // Run the ascent stage! +} ELSE { + NOTIFY("System booted but did not pass pre-flight checks, aborting excecution!"). +} diff --git a/boot/radarr_boot.ks b/boot/radarr_boot.ks index 7a1ec45..b68f956 100644 --- a/boot/radarr_boot.ks +++ b/boot/radarr_boot.ks @@ -30,6 +30,8 @@ IF true { // Set this to false to avoid compiling ascent code. COPYPATH("0:/RadarrSeries/radarr_kerbin.ks", "1:/ascent.ks"). // Copy over our launch script from the archive at ksc } +// I changed this! + NOTIFY("Program compiled and ready to run."). IF alt:radar < 100 { // If our radar alt is lower than 10 diff --git a/boot/tagBoot.ks b/boot/tagBoot.ks new file mode 100644 index 0000000..2581fb6 --- /dev/null +++ b/boot/tagBoot.ks @@ -0,0 +1,18 @@ +// Idea from JonnyOThan#0171 +// On the kOS discord. + +WAIT UNTIL ship:unpacked. +CLEARSCREEN. + +// This line from CheersKevin on youtube +core:part:getmodule("kOSProcessor"):doevent("Open Terminal"). // Open the terminal on boot! + +PRINT "Using TagBoot ver 1.0". +WAIT 5. +PRINT "Booting with tag " + core:part:tag + "...". +WAIT 5. + +// reddit says the path cant be fully qualified (no 0:/) +COPYPATH("0:/" + core:part:tag + "/boot.ks", "1:/boot/boot.ks"). +set core:bootfilename to "/boot/boot.ks". +reboot. // Reboot the FC diff --git a/libraries/abort.ks b/libraries/abort.ks index 1253c2b..8e49d3f 100644 --- a/libraries/abort.ks +++ b/libraries/abort.ks @@ -1,3 +1,6 @@ // A general abort script that prepares kOS to give up control of the rocket, and excecute the abort script. PRINT "Program tried to abort but we dident write code to do that!". + +LOCK THROTTLE TO 0. // Throttle back +SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0. // Protects the throttle from "jumping" when we hand control back to the pilot