Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @clobberbuiltins on.
- clearscreen.
- main().
- function main {
- lock steering to prograde.
- wait 5.
- unlock steering.
- unlock throttle.
- set ship:control:roll to 0.05.
- wait 1.
- set ship:control:roll to 0.
- set status1 to "All controls are unlocked.Awaiting to enter Mun sphere of influence".
- set now to time:seconds.
- set ti to time:seconds-now.
- until ship:body:name = "Mun" {
- printing().
- set ti to time:seconds-now.
- print "Left to enter Mun Sphere of Influence: " + (orbit:nextpatcheta/60) + " Minutes".
- wait 0.1.
- }
- set n to time:seconds+eta:periapsis.
- lock ti to n-time:seconds.
- set status1 to "Entered sphere of influence, awaiting for burn".
- wait 1.
- set maneuvertime to time:seconds + eta:periapsis. // when the burn should start
- set myvel to velocityat(ship,maneuvertime):orbit.
- set ap to ship:body:altitudeOf(positionAt(ship,maneuvertime))+body:radius. // altitude on burn point
- set TargetAp to ap.. // your target apoapsis.
- set smja to (ap + TargetAp) / 2. // your final semimajoraxis
- set targetvel to sqrt(body:mu*((2/ap)-(1/smja))). // target speed
- set apvel to myvel:mag. // burn point speed
- set needvel to abs(targetvel-apvel). // needed speed
- list engines in engList.
- set thr to engList[0]:maxthrust. // Engine Thrust
- set m to ship:mass. // Mass
- set e to constant():E. // E constant
- set p to engList[0]:isp. // ISP
- set g to constant:g0. // Gravitational acceleration constant.
- set burn_duration to abs(g * m * p * (1 - e^(-needvel/(g*p))) / thr). // burn duration
- print "Crude Estimated burn duration: " + round(burn_duration) + "s".
- print "Needed dv: " + abs(needvel) + " m/s".
- lock steering to retrograde.
- wait 1.
- until ti-burn_duration/2 <= 60 and ti-burn_duration/2 > 0 {
- print "To maneuver left: " + (ti-burn_duration/2) + " Seconds".
- print "Needed dv: " + abs(needvel) + " m/s".
- wait 0.1.
- printing().
- }
- set status1 to "One Minute Till Burn".
- lock steering to retrograde.
- //now we need to wait until the burn vector and ship's facing are aligned
- until vang(-ship:velocity:orbit, ship:facing:vector) < 0.25 {
- print "To maneuver left: " + (ti-burn_duration/2) + " Seconds".
- print "Needed dv: " + abs(needvel) + " m/s".
- wait 0.1.
- printing().
- }
- until ti-(burn_duration/2) <= 10 {
- print "To maneuver left: " + (ti-(burn_duration/2)) + " Seconds".
- print "Needed dv: " + abs(needvel) + " m/s".
- wait 0.1.
- printing().
- }
- set ship:control:fore to 0.5.
- set status1 to "RCS activated for ullage".
- until ti-(burn_duration/2) <= 1 {
- print "To maneuver left: " + (ti-(burn_duration/2)) + " Seconds".
- print "Needed dv: " + abs(needvel) + " m/s".
- wait 0.1.
- printing().
- }
- set ship:control:fore to 0.
- until ti-(burn_duration/2) <= 0.5 {
- print "To maneuver left: " + (ti-(burn_duration/2)) + " Seconds".
- wait 0.1.
- printing().
- }
- set now to time:seconds.
- lock ti to time:seconds - now.
- set myvel1 to ship:velocity:orbit:mag.
- set tvel to targetvel.
- lock throttle to 1.
- set status1 to "SM Engine Activated".
- until ti > burn_duration {
- set myvel1 to ship:velocity:orbit:mag.
- print "Time left: " + (burn_duration-ti) + " Seconds".
- print "Speed left: " + (tvel-myvel1) + " m/s".
- wait 0.1.
- printing().
- }
- lock throttle to max(0, 1-t/0.3).
- set status1 to "Circulization burn has completed.All controls are unlocked".
- set ship:control:fore to -1.
- wait 1.
- set ship:control:fore to 0.
- wait 5.
- unlock steering.
- unlock throttle.
- }
- function printing {
- clearscreen.
- set t to (time:seconds - now1)/60.
- print "T+: " + t + " Minutes".
- print "Status: " + status1.
- wait 0.1.
- }
Advertisement
Add Comment
Please, Sign In to add comment