Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CLEARSCREEN.
- SET linepos TO 11. //line at wich the fluight log will start printing events.
- //circularization burn req calculations here!
- //declaring variables
- SET launched TO false.
- SET burntime to 99999.
- SET launchcompleted TO false.
- PRINT "Flight status: " AT(0,0).
- PRINT "Apoapsis: " AT(0,1).
- PRINT "Orbital Velocity: " AT (0,2).
- PRINT "Req.dV for Circ.: " AT(0,3).
- PRINT "burntime: " AT(0,4).
- PRINT "Flight log: " AT(0,10).
- PRINT "Counting down to launch." AT(16,0).
- //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, wich cycles from 10 to 0.
- FROM {LOCAL countdown is 3.} UNTIL countdown = 0 STEP {SET countdown to countdown - 1.} DO {
- PRINT countdown AT(0,linepos).
- SET linepos TO linepos + 1.
- Wait 1. //Pauses script here for 1 second.
- }
- //running this program will update burnreqs
- FUNCTION setcalc {
- SET mu TO KERBIN:MU.
- SET sma TO ORBIT:SEMIMAJORAXIS.
- SET r TO KERBIN:RADIUS + SHIP:ALTITUDE.
- SET rapo TO KERBIN:RADIUS + SHIP:APOAPSIS.
- SET a TO ( mu / ( r ^ 2 ) ).
- SET aapo TO ( mu / ( rapo ^ 2 ) ).
- SET v to SQRT( a * r ).
- SET vapo to SQRT( aapo * rapo ).
- SET orbvel TO SQRT( mu * ( ( 2 / r ) - ( 1 / sma ) ) ).
- SET orbvelapo TO SQRT( mu * ( ( 2 / rapo ) - ( 1 / sma ) ) ).
- SET burnvel TO v.
- SET burnvelapo TO vapo.
- SET burnreq TO burnvelapo - orbvelapo.
- }
- FUNCTION softstage {
- LOCK THROTTLE TO 0.0.
- WAIT 0.2.
- LOCK THROTTLE TO 0.1.
- WAIT 0.2.
- LOCK THROTTLE TO 0.2.
- WAIT 0.2.
- LOCK THROTTLE TO 0.3.
- WAIT 0.2.
- LOCK THROTTLE TO 0.4.
- WAIT 0.2.
- LOCK THROTTLE TO 0.5.
- WAIT 0.2.
- LOCK THROTTLE TO 0.6.
- WAIT 0.2.
- LOCK THROTTLE TO 0.7.
- WAIT 0.2.
- LOCK THROTTLE TO 0.8.
- WAIT 0.2.
- LOCK THROTTLE TO 0.9.
- WAIT 0.2.
- LOCK THROTTLE TO 1.0.
- }
- FUNCTION calc_burn {
- SET max_acc TO SHIP:MAXTHRUST/SHIP:MASS.
- SET burntime TO burnreq/max_acc.
- }
- FUNCTION circularize {
- LOCK STEERING TO HEADING(90,0).
- UNTIL PERIAPSIS > 99999 {
- LOCK THROTTLE TO 1.0.
- }
- LOCK throttle TO 0.0.
- PRINT "Circularization complete." AT(0,linepos).
- }
- WHEN SHIP:ALTITUDE < 250 AND MAXTHRUST = 0 THEN {
- PRINT "Staging." AT(0,linepos).
- SET linepos TO linepos + 1.
- STAGE.
- SET launched TO true.
- PRESERVE.
- }
- WHEN SHIP:ALTITUDE >= 250 AND MAXTHRUST = 0 THEN {
- PRINT "Staging." AT(0,linepos).
- SET linepos TO linepos + 1.
- STAGE.
- PRESERVE.
- }
- UNTIL PERIAPSIS > 97500 {
- setcalc().
- PRINT ROUND(burnreq) AT(18,3).
- PRINT ROUND(orbvel) AT(19,2).
- PRINT burntime AT(11,4).
- IF launched = true {
- calc_burn().
- }
- IF ETA:APOAPSIS < (0.5*burntime) AND launchcompleted = true {
- PRINT "Starting Circularization" AT(16,0).
- circularize.
- BREAK.
- }
- UNTIL APOAPSIS > 100000 {
- IF launched = true {
- calc_burn().
- }
- setcalc().
- PRINT ROUND(burnreq) AT(18,3).
- PRINT ROUND(orbvel) AT(19,2).
- IF SHIP:VELOCITY:SURFACE:MAG < 100 {
- LOCK STEERING TO HEADING(90,90).
- PRINT "Pitching to 90 degrees." AT(16,0).
- PRINT ROUND(orbvel) AT(19,2).
- PRINT ROUND(burnreq) AT(18,3).
- PRINT burntime AT(11,4).
- } ELSE IF SHIP:VELOCITY:SURFACE:MAG >= 100 AND SHIP:VELOCITY:SURFACE:MAG < 200 {
- LOCK STEERING TO HEADING(90,80).
- PRINT "Pitching to 80 degrees." AT(16,0).
- PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
- PRINT ROUND(orbvel) AT(19,2).
- PRINT ROUND(burnreq) AT(18,3).
- PRINT burntime AT(11,4).
- } Else IF SHIP:VELOCITY:SURFACE:MAG >= 200 AND SHIP:VELOCITY:SURFACE:MAG < 300 {
- LOCK STEERING TO HEADING(90,70).
- PRINT "Pitching to 70 degrees." AT(16,0).
- PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
- PRINT ROUND(orbvel) AT(19,2).
- PRINT ROUND(burnreq) AT(18,3).
- PRINT burntime AT(11,4).
- } Else IF SHIP:VELOCITY:SURFACE:MAG >= 300 AND SHIP:VELOCITY:SURFACE:MAG < 400 {
- LOCK STEERING TO HEADING(90,60).
- PRINT "Pitching to 60 degrees." AT(16,0).
- PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
- PRINT ROUND(orbvel) AT(19,2).
- PRINT ROUND(burnreq) AT(18,3).
- PRINT burntime AT(11,4).
- } Else IF SHIP:VELOCITY:SURFACE:MAG >= 400 AND SHIP:VELOCITY:SURFACE:MAG < 500 {
- LOCK STEERING TO HEADING(90,50).
- PRINT "Pitching to 50 degrees." AT(16,0).
- PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
- PRINT ROUND(orbvel) AT(19,2).
- PRINT ROUND(burnreq) AT(18,3).
- PRINT burntime AT(11,4).
- } Else IF SHIP:VELOCITY:SURFACE:MAG >= 500 AND SHIP:VELOCITY:SURFACE:MAG < 600 {
- LOCK STEERING TO HEADING(90,40).
- PRINT "Pitching to 40 degrees." AT(16,0).
- PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
- PRINT ROUND(orbvel) AT(19,2).
- PRINT ROUND(burnreq) AT(18,3).
- PRINT burntime AT(11,4).
- } Else IF SHIP:VELOCITY:SURFACE:MAG >= 600 AND SHIP:VELOCITY:SURFACE:MAG < 700 {
- LOCK STEERING TO HEADING(90,30).
- PRINT "Pitching to 30 degrees." AT(16,0).
- PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
- PRINT ROUND(orbvel) AT(19,2).
- PRINT ROUND(burnreq) AT(18,3).
- PRINT burntime AT(11,4).
- } Else IF SHIP:VELOCITY:SURFACE:MAG >= 700 AND SHIP:VELOCITY:SURFACE:MAG < 800 {
- LOCK STEERING TO HEADING(90,20).
- PRINT "Pitching to 20 degrees." AT(16,0).
- PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
- PRINT ROUND(orbvel) AT(19,2).
- PRINT ROUND(burnreq) AT(18,3).
- PRINT burntime AT(11,4).
- } Else IF SHIP:VELOCITY:SURFACE:MAG >= 800 {
- LOCK STEERING TO HEADING(90,10).
- PRINT "Pitching to 10 degrees." AT(16,0).
- PRINT ROUND(SHIP:APOAPSIS,0) AT (11,1).
- PRINT ROUND(orbvel) AT(19,2).
- PRINT ROUND(burnreq) AT(18,3).
- PRINT burntime AT(11,4).
- }
- }
- LOCK THROTTLE TO 0.0.
- LOCK STEERING TO HEADING(90,0).
- PRINT "Apoapsis of 100km reached." AT(0,linepos).
- SET launchcompleted TO true.
- }
- PRINT "In orbit. Have a nice flight!" AT(16,0).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement