Jump to content

(KOS) Mission Script Pack


jandor

Recommended Posts

Hello there.

What if we collect simple code snippets here? Would it be a spoiler for a new KOS users? I really like this mod.

Here is my simple stuff.

jump


stage.
lock throttle to 1.
wait until alt:radar > 100.
lock throttle to 0.
unlock throttle.

launch - not really mine, stolen from somewhere


print "Launch!".
lock steering to up.
lock throttle to 1.
stage.

when stage:solidfuel = 0 then stage.

print "Wait for 10k".
wait until altitude >10000.

print "Gravity turn".
lock steering to heading 90 by 45.
wait until apoapsis > 75000.

print "Stop engines".
lock throttle to 0.

print "Waiting till apoapsis".
wait until eta:apoapsis < 3.

print "Circularization burn".
lock steering to prograde.
lock throttle to 1.
wait until periapsis > 75000.

lock throttle to 0.
unlock all.
print "done".

circularize


if (periapsis < 70000) {

print "waiting for apoapsis to higher periapsis".
lock steering to prograde.
until (eta:apoapsis < 10){
print eta:apoapsis.
wait 2.
}.
print "burning to get over 70 km".
print "engage!".
lock throttle to 1.
until (periapsis > 70000){
print periapsis.
wait 0.1.
}.
unlock throttle.
}

if apoapsis > 90000{
print "waiting to periapsis to lower apoapsis".
lock steering to retrograde.
until (eta:periapsis < 5){
print eta:periapsis.
wait 2.
}
print "lowering apoapsis to 90 km".
print "engage!".
lock throttle to 1.
until (apoapsis < 90000){
print apoapsis.
wait 0.1.
}
}

deorbit


print "waiting for apoapsis".
lock steering to retrograde.
until (eta:apoapsis < 5){
print eta:apoapsis.
wait 2.
}
print "lowering apoapsis to 40 km".
lock throttle to 1.
until (periapsis < 40000){
print periapsis.
wait 0.1.
}

powerland


lock g to constant():g * body:mass / (body:radius + altitude) ^ 2.
lock weight to mass * g.
lock maxtwr to maxthrust/ weight.
lock twr to maxtwr * throttle.
lock maxacc to maxthrust / mass.
lock safeacc to 0.6 * maxacc - g .
lock t to -verticalspeed / safeacc.
lock brakedistance to (verticalspeed)^2 / (2 * safeacc).


print "all ready, waiting for descent".
wait until verticalspeed < 0.

print "descent started".
when alt:radar < 100 then legs on.
lock steering to srfretrograde.

until alt:radar < 2{

if alt:radar < brakedistance {
lock throttle to 1.
} else
if alt:radar < 100
lock throttle to 1/maxtwr.
else
lock throttle to 0.
print "v "+round(verticalspeed)+"| r " + round(alt:radar) + "| b "+round(brakedistance) + "| th "+throttle.

wait 0.1.
}.
wait 0.1.

unlock steering.
unlock throttle.
sas on.

print "done".

I'll update this post based on your ideas and suggestions. Please, tell me what you think about it.

Link to comment
Share on other sites

  • 1 month later...

Thanks Jandor for posting these scripts. They are very useful for getting me started.

I look forward to possible seeing more code snippets.

I'd also be interested in any links toy useful resources you've found.

So far I've found:

Reusable Launch System Scripts

Reddit Universal Script

Orbital Mechanics Related:

Orbital Mechanics Basics

Edited by Swifty
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...