Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clearscreen.
- set Kputsnis to SHIP.
- set firststage to Kputsnis:PARTSTAGGED("firststage").
- set secondstage to Kputsnis:PARTSTAGGED("secondstage").
- set counter to 1.
- set TARGET_APO to 80000.
- set TARGET_PER to 80000.
- set TARGET_SMA to (TARGET_APO + TARGET_PER)/2.
- lock SMA to (apoapsis + periapsis)/2.
- set thr to 0.
- set tick to 0.01.
- set taim to 0.
- set captabel to false.
- set incl to 90.
- set direction to heading(incl,90).
- set pitch to 90.
- set stage_1_complete to false.
- set stage_2_complete to false.
- set orbital to false.
- set orbit_reached to false.
- lock steering to direction.
- lock throttle to thr.
- function clearmessages
- {
- print " " at (3,30).
- print " " at (3,31).
- print " " at (3,32).
- }.
- until counter = 50
- {
- print "=" at (counter,0).
- print "=" at (counter,34).
- print "-" at (counter,28).
- print "-" at (counter,6).
- set counter to counter + 1.
- }.
- set counter to 1.
- until counter = 33
- {
- print "|" at (0,counter).
- print "|" at (50,counter).
- set counter to counter +1.
- }.
- set counter to 1.
- until counter = 28
- {
- print "|" at (25,counter).
- set counter to counter +1.
- }.
- print " FLIGHT DATA " at (5,0).
- print " System messages: " at (5,28).
- print " TELEMETRY " at (8,3).
- print " PROJECTIONS " at (32,3).
- until 0 = 1
- {
- print ship:body at (6,8).
- if altitude < 1000 print " Altitude(km): 0" at (5,11).
- if altitude > 1000
- print " Altitude(km): " + (altitude - mod(altitude,1000))/1000 at (5,11).
- print " Speed(m/s): " + ((ship:airspeed - mod(ship:airspeed,1)) + " ") at (5,14).
- print " Throttle: " + throttle / 0.01 + "% " at (5,17).
- print " Mass (t): " + (ship:mass - mod(ship:mass,1)) at (5,20).
- print " Apoapsis(km):" + ((apoapsis - mod(apoapsis,1000))/1000 + " ") at (29,8).
- if periapsis < 0 print " Periapsis(km): 0" at (29,11).
- if periapsis > 0 print " Periapsis(km):" + (periapsis - mod(periapsis,1000))/1000 + " " at (29,11).
- // staging controls
- if (ship:airspeed < 0.1) and (altitude < 100)
- {
- print " " at (3,30).
- print "Initialising flight parameters" at (3,30).
- set direction to heading(incl,85).
- set thr to 0.1.
- print " " at (3,31).
- print "Setting up flight log" at (3,31).
- set skipl0g to ship:name.
- set skipl0g to skipl0g + ".csv".
- switch to archive.
- delete skipl0g.
- if captabel = false
- {
- log "Time,Altitude,Speed (x10),Throttle,Apoapsis,Periapsis" to skipl0g.
- set captabel to true.
- }.
- switch to 1.
- set pitch to 80.
- stage.
- print "Booster ignition" at (3,32).
- wait 3.
- set taim to taim + 3.
- }.
- if stage_1_complete = false
- {
- clearmessages().
- print "Stage 1 Commencing..." at (3,30).
- if firststage[0]:flameout
- {
- print "Stage 1 completed: discarding booster" at (3,31).
- wait 1.
- set taim to taim + 1.
- stage.
- wait 1.
- set taim to taim + 1.
- stage.
- set stage_1_complete to true.
- clearmessages().
- print "Stage 2 Commencing..." at (3,30).
- }.
- }.
- if stage_1_complete and (stage_2_complete = false)
- {
- if secondstage[0]:flameout and (stage_2_complete = false)
- {
- print "Second stage completed: staging..." at (3,32).
- set stage_2_complete to true.
- stage.
- wait 1.
- set taim to taim + 1.
- stage.
- }.
- }.
- // navigational controls
- // nav 1. - maneuvres if suborbital or on decaying orbit
- if (orbital = false) and (orbit_reached = false)
- {
- if (apoapsis/TARGET_APO < 0.9) and (apoapsis < TARGET_APO) set thr to 1.
- if ((apoapsis/TARGET_APO > 0.9) and (altitude < TARGET_APO)) and (apoapsis < TARGET_APO) set thr to 0.5.
- if (altitude < TARGET_APO) and (apoapsis > TARGET_APO)
- {
- print "Adjusting pitch angle to:" + pitch + " degrees "at (3,31).
- set pitch to (85 - ((85*apoapsis)/TARGET_APO - mod((85*apoapsis)/TARGET_APO,1))).
- set direction to heading(incl,pitch).
- }.
- if (apoapsis > TARGET_APO) and ((eta:apoapsis > 10) and (eta:apoapsis < eta:periapsis)) set thr to 0.
- if (apoapsis < TARGET_APO)
- {
- print "Adjusting pitch angle to:" + pitch + " degrees "at (3,31).
- set pitch to (85 - ((85*apoapsis)/TARGET_APO - mod((85*apoapsis)/TARGET_APO,1))).
- set direction to heading(incl,pitch).
- }.
- if (apoapsis > TARGET_APO) and ((eta:apoapsis < 10) and (eta:apoapsis < eta:periapsis)) and (periapsis < TARGET_PER)
- {
- unlock steering.
- lock steering to prograde.
- if periapsis < 0 set thr to 1.
- if periapsis > 0 set thr to (1 - periapsis/TARGET_PER).
- }.
- }.
- // check if orbital
- if (apoapsis > 70000) and (periapsis > 70000) and (SMA > TARGET_SMA)
- {
- clearmessages().
- print "ORBIT ACHIEVED" at (3,31).
- set orbital to true.
- unlock steering.
- set thr to 0.
- }.
- // adjust orbit
- // flight recorder below this point
- switch to archive.
- set spid to ship:airspeed.
- set apogeu to apoapsis.
- set perigeu to periapsis.
- if periapsis < 0 set perigeu to 0.
- log taim + "," + altitude + "," + spid*10 + "," + (thr/(1/100)) + "," + apogeu + "," + perigeu + "," to skipl0g.
- switch to 1.
- wait tick.
- set taim to taim + tick.
- }.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement