Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FUNCTION PRINT_AT {
- PARAMETER DESCRIPTION.
- PARAMETER TEXT.
- PARAMETER STRING_NUM.
- PRINT DESCRIPTION AT(0,STRING_NUM) + " " + TEXT AT(0,STRING_NUM).
- }.
- FUNCTION CIRCLING_FROM_PERIAPSIS {
- //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
- PRINT "Disable engine".
- LOCK THROTTLE TO 0.
- PRINT "Waiting to rich APOAPSIS".
- UNTIL (ETA:APOAPSIS < 30) {
- SET MYSTEER TO HEADING(90,0).
- PRINT "Pitching to 0 degrees" AT(0,15).
- PRINT_AT("APOAPSIS",ROUND(SHIP:APOAPSIS,0),16).
- PRINT_AT("ALTITUDE",ROUND(SHIP:ALTITUDE,0),17).
- PRINT_AT("ETA:APOAPSIS",ETA:APOAPSIS,18).
- }.
- PRINT "Pitching to 0 degrees".
- SET MYSTEER TO HEADING(90,0).
- LOCK THROTTLE TO 1.0.
- UNTIL (ABS((SHIP:APOAPSIS - SHIP:PERIAPSIS)/SHIP:PERIAPSIS) < 0.05 ) {
- PRINT_AT("SHIP:APOAPSIS",SHIP:APOAPSIS,15).
- PRINT_AT("SHIP:PERIAPSIS",SHIP:PERIAPSIS,17).
- PRINT_AT("ABS(SHIP:APOAPSIS - SHIP:PERIAPSIS)",ABS(SHIP:APOAPSIS - SHIP:PERIAPSIS),23).
- IF ETA:APOAPSIS { BREAK. }
- }.
- LOCK THROTTLE TO 0.
- }.
- //hellolaunch
- //First, we'll clear the terminal screen to make it look nice
- CLEARSCREEN.
- //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 < 800 {
- SET PITCH_ANG TO (SHIP:ALTITUDE - 24033)/(-282).
- SET MYSTEER TO HEADING(90,ROUND(PITCH_ANG,0)).
- PRINT "Pitching to " + PITCH_ANG + " degrees" AT(0,15).
- PRINT_AT("APOAPSIS",ROUND(SHIP:APOAPSIS,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_AT("APOAPSIS",ROUND(SHIP:APOAPSIS,0),16).
- PRINT_AT("ALTITUDE",ROUND(SHIP:ALTITUDE,0),18).
- }.
- }.
- CLEARSCREEN.
- PRINT "100 km apoapsis reached, cutting throttle".
- SET MYSTEER TO HEADING(90,0).
- PRINT "Pitching to 0 degrees".
- CIRCLING_FROM_PERIAPSIS()
- //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.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement