This does not work at all XD! Needs work!
This commit is contained in:
parent
9938f4b48e
commit
7cbd00f241
|
@ -0,0 +1,26 @@
|
||||||
|
// 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 section from latest docs.
|
||||||
|
wait until ship:unpacked.
|
||||||
|
clearscreen.
|
||||||
|
|
||||||
|
FUNCTION NOTIFY {
|
||||||
|
PARAMETER message.
|
||||||
|
HUDTEXT("kOS: " + message, 5, 2, 50, WHITE, false).
|
||||||
|
PRINT message.
|
||||||
|
}
|
||||||
|
|
||||||
|
NOTIFY("Program booted!").
|
||||||
|
|
||||||
|
IF ALT:RADAR < 100 { // If our radar alt is lower than 10
|
||||||
|
WAIT 5.
|
||||||
|
COPY radarr.kerbin.ks FROM 0. // Copy in a prototyping script
|
||||||
|
RUN radarr.kerbin.ks. // Run the script we coppied over
|
||||||
|
} else {
|
||||||
|
NOTIFY("System booted but did not pass pre-flight checks, aborting excecution!").
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
// Written based off CheersKevin's youtube series
|
||||||
|
// On programming in KOS
|
||||||
|
|
||||||
|
FUNCTION NOTIFY {
|
||||||
|
PARAMETER message.
|
||||||
|
HUDTEXT("kOS: " + message, 5, 2, 50, WHITE, false).
|
||||||
|
}
|
||||||
|
|
||||||
|
NOTIFY("Program booted!").
|
||||||
|
|
||||||
|
IF ALT:RADAR < 100 { // If our radar alt is lower than 10
|
||||||
|
WAIT 10.
|
||||||
|
COPY proto.proto1.ks FROM 0. // Copy in a prototyping script
|
||||||
|
RUN proto.proto1.ks. // Run the script we coppied over
|
||||||
|
} else {
|
||||||
|
NOTIFY("System booted but did not pass pre-flight checks, aborting excecution!").
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
// This function alows you to specify a variable length countdown timer.
|
||||||
|
// Useful for all sorts of things!
|
||||||
|
|
||||||
|
function count_down {
|
||||||
|
parameter counts is 10. // Number of counts to do
|
||||||
|
parameter duration_per_count is 1. // Duration per each count
|
||||||
|
|
||||||
|
PRINT "Counting down:".
|
||||||
|
FROM {local countdown is counts.} UNTIL countdown = 0 STEP {SET countdown to countdown - 1.} DO {
|
||||||
|
PRINT "..." + countdown. // Print out the current count.
|
||||||
|
WAIT duration_per_count. // Pause here untill the duration is complete.
|
||||||
|
}.
|
||||||
|
}.
|
|
@ -0,0 +1,102 @@
|
||||||
|
//hellolaunch
|
||||||
|
|
||||||
|
//First, we'll clear the terminal screen to make it look nice
|
||||||
|
CLEARSCREEN.
|
||||||
|
|
||||||
|
NOTIFY("HERE WE GO.").
|
||||||
|
|
||||||
|
//Next, we'll lock our throttle to 100%.
|
||||||
|
LOCK THROTTLE TO 1.0. // 1.0 is the max, 0.0 is idle.
|
||||||
|
|
||||||
|
//This is our countdown loop, which cycles from 10 to 0
|
||||||
|
PRINT "Counting down:".
|
||||||
|
FROM {local countdown is 10.} UNTIL countdown = 0 STEP {SET countdown to countdown - 1.} DO {
|
||||||
|
PRINT "..." + countdown.
|
||||||
|
WAIT 1. // pauses the script here for 1 second.
|
||||||
|
}
|
||||||
|
|
||||||
|
//This is a trigger that constantly checks to see if our thrust is zero.
|
||||||
|
//If it is, it will attempt to stage and then return to where the script
|
||||||
|
//left off. The PRESERVE keyword keeps the trigger active even after it
|
||||||
|
//has been triggered.
|
||||||
|
WHEN MAXTHRUST = 0 THEN {
|
||||||
|
PRINT "Staging".
|
||||||
|
STAGE.
|
||||||
|
PRESERVE.
|
||||||
|
}.
|
||||||
|
|
||||||
|
//This will be our main control loop for the ascent. It will
|
||||||
|
//cycle through continuously until our apoapsis is greater
|
||||||
|
//than 100km. Each cycle, it will check each of the IF
|
||||||
|
//statements inside and perform them if their conditions
|
||||||
|
//are met
|
||||||
|
SET MYSTEER TO HEADING(90,90).
|
||||||
|
LOCK STEERING TO MYSTEER. // from now on we'll be able to change steering by just assigning a new value to MYSTEER
|
||||||
|
UNTIL SHIP:APOAPSIS > 100000 { //Remember, all altitudes will be in meters, not kilometers
|
||||||
|
|
||||||
|
//For the initial ascent, we want our steering to be straight
|
||||||
|
//up and rolled due east
|
||||||
|
IF SHIP:VELOCITY:SURFACE:MAG < 100 {
|
||||||
|
//This sets our steering 90 degrees up and yawed to the compass
|
||||||
|
//heading of 90 degrees (east)
|
||||||
|
SET MYSTEER TO HEADING(90,90).
|
||||||
|
|
||||||
|
//Once we pass 100m/s, we want to pitch down ten degrees
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 100 AND SHIP:VELOCITY:SURFACE:MAG < 200 {
|
||||||
|
SET MYSTEER TO HEADING(90,80).
|
||||||
|
PRINT "Pitching to 80 degrees" AT(0,15).
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
//Each successive IF statement checks to see if our velocity
|
||||||
|
//is within a 100m/s block and adjusts our heading down another
|
||||||
|
//ten degrees if so
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 200 AND SHIP:VELOCITY:SURFACE:MAG < 300 {
|
||||||
|
SET MYSTEER TO HEADING(90,70).
|
||||||
|
PRINT "Pitching to 70 degrees" AT(0,15).
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 300 AND SHIP:VELOCITY:SURFACE:MAG < 400 {
|
||||||
|
SET MYSTEER TO HEADING(90,60).
|
||||||
|
PRINT "Pitching to 60 degrees" AT(0,15).
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 400 AND SHIP:VELOCITY:SURFACE:MAG < 500 {
|
||||||
|
SET MYSTEER TO HEADING(90,50).
|
||||||
|
PRINT "Pitching to 50 degrees" AT(0,15).
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 500 AND SHIP:VELOCITY:SURFACE:MAG < 600 {
|
||||||
|
SET MYSTEER TO HEADING(90,40).
|
||||||
|
PRINT "Pitching to 40 degrees" AT(0,15).
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 600 AND SHIP:VELOCITY:SURFACE:MAG < 700 {
|
||||||
|
SET MYSTEER TO HEADING(90,30).
|
||||||
|
PRINT "Pitching to 30 degrees" AT(0,15).
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 700 AND SHIP:VELOCITY:SURFACE:MAG < 800 {
|
||||||
|
SET MYSTEER TO HEADING(90,11).
|
||||||
|
PRINT "Pitching to 20 degrees" AT(0,15).
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
//Beyond 800m/s, we can keep facing towards 10 degrees above the horizon and wait
|
||||||
|
//for the main loop to recognize that our apoapsis is above 100km
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 800 {
|
||||||
|
SET MYSTEER TO HEADING(90,10).
|
||||||
|
PRINT "Pitching to 10 degrees" AT(0,15).
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
}.
|
||||||
|
|
||||||
|
}.
|
||||||
|
|
||||||
|
PRINT "100km apoapsis reached, cutting throttle".
|
||||||
|
|
||||||
|
//At this point, our apoapsis is above 100km and our main loop has ended. Next
|
||||||
|
//we'll make sure our throttle is zero and that we're pointed prograde
|
||||||
|
LOCK THROTTLE TO 0.
|
||||||
|
|
||||||
|
//This sets the user's throttle setting to zero to prevent the throttle
|
||||||
|
//from returning to the position it was at before the script was run.
|
||||||
|
SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.
|
|
@ -0,0 +1,102 @@
|
||||||
|
//First, we'll clear the terminal screen to make it look nice
|
||||||
|
CLEARSCREEN.
|
||||||
|
|
||||||
|
NOTIFY("Software loaded and ready to takeoff.").
|
||||||
|
|
||||||
|
//Next, we'll lock our throttle to 100%.
|
||||||
|
LOCK THROTTLE TO 1.0. // 1.0 is the max, 0.0 is idle.
|
||||||
|
|
||||||
|
//This is our countdown loop, which cycles from 10 to 0
|
||||||
|
PRINT "Counting down:".
|
||||||
|
FROM {local countdown is 10.} UNTIL countdown = 0 STEP {SET countdown to countdown - 1.} DO {
|
||||||
|
PRINT "..." + countdown.
|
||||||
|
WAIT 1. // pauses the script here for 1 second.
|
||||||
|
}
|
||||||
|
|
||||||
|
//This is a trigger that constantly checks to see if our thrust is zero.
|
||||||
|
//If it is, it will attempt to stage and then return to where the script
|
||||||
|
//left off. The PRESERVE keyword keeps the trigger active even after it
|
||||||
|
//has been triggered.
|
||||||
|
WHEN MAXTHRUST = 0 THEN {
|
||||||
|
NOTIFY("Staging").
|
||||||
|
STAGE.
|
||||||
|
PRESERVE.
|
||||||
|
}.
|
||||||
|
|
||||||
|
//This will be our main control loop for the ascent. It will
|
||||||
|
//cycle through continuously until our apoapsis is greater
|
||||||
|
//than 100km. Each cycle, it will check each of the IF
|
||||||
|
//statements inside and perform them if their conditions
|
||||||
|
//are met
|
||||||
|
SET MYSTEER TO HEADING(90,90).
|
||||||
|
LOCK STEERING TO MYSTEER. // from now on we'll be able to change steering by just assigning a new value to MYSTEER
|
||||||
|
UNTIL SHIP:APOAPSIS > 100000 { //Remember, all altitudes will be in meters, not kilometers
|
||||||
|
|
||||||
|
//For the initial ascent, we want our steering to be straight
|
||||||
|
//up and rolled due east
|
||||||
|
IF SHIP:VELOCITY:SURFACE:MAG < 100 {
|
||||||
|
//This sets our steering 90 degrees up and yawed to the compass
|
||||||
|
//heading of 90 degrees (east)
|
||||||
|
SET MYSTEER TO HEADING(90,90).
|
||||||
|
|
||||||
|
//Once we pass 100m/s, we want to pitch down ten degrees
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 100 AND SHIP:VELOCITY:SURFACE:MAG < 200 {
|
||||||
|
SET MYSTEER TO HEADING(90,80).
|
||||||
|
NOTIFY("Pitching to 80 degrees").
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
//Each successive IF statement checks to see if our velocity
|
||||||
|
//is within a 100m/s block and adjusts our heading down another
|
||||||
|
//ten degrees if so
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 200 AND SHIP:VELOCITY:SURFACE:MAG < 300 {
|
||||||
|
SET MYSTEER TO HEADING(90,70).
|
||||||
|
NOTIFY("Pitching to 70 degrees").
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 300 AND SHIP:VELOCITY:SURFACE:MAG < 400 {
|
||||||
|
SET MYSTEER TO HEADING(90,60).
|
||||||
|
NOTIFY("Pitching to 60 degrees").
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
STAGE.
|
||||||
|
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 400 AND SHIP:VELOCITY:SURFACE:MAG < 500 {
|
||||||
|
SET MYSTEER TO HEADING(90,50).
|
||||||
|
NOTIFY("Pitching to 50 degrees").
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 500 AND SHIP:VELOCITY:SURFACE:MAG < 600 {
|
||||||
|
SET MYSTEER TO HEADING(90,40).
|
||||||
|
NOTIFY("Pitching to 40 degrees").
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
STAGE.
|
||||||
|
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 600 AND SHIP:VELOCITY:SURFACE:MAG < 700 {
|
||||||
|
SET MYSTEER TO HEADING(90,30).
|
||||||
|
NOTIFY("Pitching to 30 degrees").
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 700 AND SHIP:VELOCITY:SURFACE:MAG < 800 {
|
||||||
|
SET MYSTEER TO HEADING(90,11).
|
||||||
|
NOTIFY("Pitching to 20 degrees").
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
//Beyond 800m/s, we can keep facing towards 10 degrees above the horizon and wait
|
||||||
|
//for the main loop to recognize that our apoapsis is above 100km
|
||||||
|
} ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 800 {
|
||||||
|
SET MYSTEER TO HEADING(90,10).
|
||||||
|
NOTIFY("Pitching to 10 degrees").
|
||||||
|
PRINT ROUND(SHIP:APOAPSIS,0) AT (0,16).
|
||||||
|
|
||||||
|
}.
|
||||||
|
|
||||||
|
}.
|
||||||
|
|
||||||
|
NOTIFY("100km apoapsis reached, cutting throttle").
|
||||||
|
|
||||||
|
//At this point, our apoapsis is above 100km and our main loop has ended. Next
|
||||||
|
//we'll make sure our throttle is zero and that we're pointed prograde
|
||||||
|
LOCK THROTTLE TO 0.
|
||||||
|
|
||||||
|
//This sets the user's throttle setting to zero to prevent the throttle
|
||||||
|
//from returning to the position it was at before the script was run.
|
||||||
|
SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.
|
Loading…
Reference in New Issue