Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- declare PARAMETER aimvalue.
- //how precise do you want to be? 1.01 = 1% difference.
- //BOOT PROCESS - STAGE FUNCTION COPIED.
- DECLARE FUNCTION STAGEPROCESS {
- LIST ENGINES IN SHIPENG.
- SET numOut TO 0.
- if stage:number > 0 AND THROTTLE > 0.01 {
- FOR eng IN SHIPENG {
- IF eng:FLAMEOUT {
- SET numOut TO numOut + 1.
- }
- }
- IF MAXTHRUST = 0 {
- PRINT "...STAGING." + STAGE:NUMBER. //AT (0,20)
- SET numOut TO numOut + 1.
- }
- }
- if numOut >0 {stage.
- wait 1.}
- }
- //BASE DATA (from orbit script)
- LOCK DIR to 90.
- LOCK DIRPLAN7 to HEADING (DIR,90).
- LOCK DIRPLAN8 to HEADING (DIR,-90).
- //MARGIN DESIGN - how much time before and after the manoeuver is acceptable.
- LOCK MARGalt to MIN((22500*(aimvalue-1.01)+100),1000).
- //CIRCULARISATION VALUES.
- SET BASECIRCA to (alt:apoapsis/alt:periapsis).
- LOCK CIRCA to (alt:apoapsis/alt:periapsis).
- set MIDALTMAX to (((alt:apoapsis+alt:periapsis)/2) + MARGalt).
- set midalt to ((alt:apoapsis+alt:periapsis)/2).
- set MIDALTMIN to (((alt:apoapsis+alt:periapsis)/2) - MARGalt).
- LOCK doradup to false.
- LOCK doradown to false.
- //DECLARE CONDITIONS TO RADUP AND RADDOWN
- declare function RADUPCONDITIONS {
- if ( circa > aimvalue AND
- ship:verticalspeed < 0 AND
- ship:altitude < MIDALTMAX AND
- ship:altitude > MIDALT
- ) {
- set doradup TO true.
- //RADUP.
- }
- wait 0.001.
- }
- declare function RADOWNCONDITIONS {
- if ( circa > aimvalue AND
- ship:verticalspeed > 0 AND
- ship:altitude > MIDALTMIN AND
- ship:altitude < MIDALT
- ) {
- set doradown TO true.
- // RADOWN.
- }
- wait 0.001.
- }
- //this is the problem. I want to say IF CIRCA INCREASE THEN .....
- declare function failsafe {
- if basecirca < circa {
- set doradown to false.
- set doradup to false.
- SET BASECIRCA to (alt:apoapsis/alt:periapsis).
- set MIDALTMAX to (((alt:apoapsis+alt:periapsis)/2)+1000).
- set midalt to ((alt:apoapsis+alt:periapsis)/2).
- set MIDALTMIN to (((alt:apoapsis+alt:periapsis)/2)-1000).
- }
- }
- //DECLARE MANOEUVERS FOR RADUP AND RADDOWN
- declare function RADUP {
- rcs on.
- PRINT "1A-ADJUSTING RADIALup" at (0,33).
- LOCK STEERING to DIRPLAN7.
- wait 1.
- PRINT "GO!"at (0,33).
- lock throttle to 0.5.
- wait 0.01.
- }
- declare function RADOWN {
- rcs on.
- PRINT "1B-ADJUSTING RADIALdown" at (0,33).
- LOCK STEERING to DIRPLAN8.
- wait 1.
- PRINT "GO!"at (0,33).
- lock throttle to 0.5.
- wait 0.01.
- }
- //CIRCULARIZE
- until circa < aimvalue {
- STAGEPROCESS.
- PRINT "basecirca " + ROUND (circa,3) + " " AT (0,26).
- PRINT "circa " + ROUND (circa,3) + " " AT (0,27).
- PRINT "midaltMIN " + ROUND (midaltMIN,3) + " " AT (0,28).
- PRINT "midaltMAX " + ROUND (midaltMAX,3) + " " AT (0,29).
- PRINT "target altitude " + ROUND (midalt,3) + " " AT (0,30).
- failsafe.
- RADOWNCONDITIONS.
- RADUPCONDITIONS.
- if doradup {radup.}
- else if doradown {radown.}
- else if ( doradup = false AND
- doradown = false
- ) {set throttle to 0.
- SET BASECIRCA to (alt:apoapsis/alt:periapsis).}
- wait 0.01.
- }
- //CLOSING PROGRAM
- if CIRCA < aimvalue {
- LOCK THROTTLE TO 0.0.
- LOCK STEERING TO PROGRADE.
- PRINT " ".
- PRINT "--CIRCULARIZATION SUCCESS--".
- PRINT "NEW DIFFERENTIAL DATA:" + ROUND (circa,3).
- SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.
- RCS OFF.
- }
Advertisement
Add Comment
Please, Sign In to add comment