Jump to content

SpaceCore kOS Script Pack


bodryxon

Recommended Posts

SpaceCore kOS Script Pack

Version 1.1.1

 

What it is

SpaceCore is a pack of scripts for kOS mod to launch and operate your rockets. It is universal and can be used for most launch vehicles and spacecraft. You can use the scripts separately or combine them in your own flight programs.

I’m quite new to kOS and coding in general and the code may be far from perfect, but I am open to any recommendations.

If you've got any questions or ideas for new features, feel free to address them below.

 

Installation

SpaceDock

GitHub

kOS (required to run scripts)

Unzip the archive into your KSP folder. It can be done while KSP is running, there is no need to restart the game.

Before updating it is recommended to delete previous version of the pack.

License: MIT

 

How to use

To use the scripts, you have to run them in kOS console like you would run any other kOS script. It is done by entering the command run [script name].

Example: run  Eject.

where Eject is the name of the script

 

Some scripts in the pack can be launched with specific parameters (orbit inclination, altitude etc.). It is done by entering the command run [script name]([parameter 1],[parameter 2]…).

Example: run SHohmann(100,120).

where 100 is periapsis altitude and 120 is apoapsis altitude in kilometers

 

If you don't enter the parameters when running a script, default parameters will be used (they can be changed in script files).

 

Important: to run the scripts by "run" command you have to run dir.ks by entering run dir.

 

Scripts

Spoiler

dir

Changes your default directory for scripts to SpaceCore folder to run scripts easier (run [script name] instead of runpath("0:/SpaceCore/[script name]"). Directory can be changed back to default by running the same command: run dir. (the script is duplicated to SpaceCore folder, but instead of changing directory to SpaceCore it returns it to Archive)

 

Countdown

Performs a countdown from -10 to 0 seconds and displays the timer. Only works if the spacecraft isn’t moving (can be modified in the script file). The amount of seconds the timer is set to can be changed in the script file.

 

Liftoff

Performs a liftoff of your vehicle. Works with launch clamps (although they all have to be as one stage) and/or with already working engines. Time between ignition and separation from the clamps is customizable in the script file.

 

Ascent

Performs the ascent of your vehicle to a desired apoapsis. It contains a pitch program, a staging program (suitable for any number of stages) and a cutoff program to switch to coast mode.

Important: when entering a command to run this script you can add three parameters in parentheses with commas between – fairing separation (true or false), orbit altitude (in kilometers) and relative inclination (in degrees). Relative inclination will become your orbit inclination (± several degrees) if launching from the equator. Fairing separation stage has to come after the last stage used for the ascent. By default fairing separation is disabled, orbit altitude is set to 75 km and relative inclination is set to 0 degrees (launch to east).

Example: run Ascent(true,80,30).

will launch your vehicle into an orbit with an altitude of 80 km and a relative inclination of 30 degrees, fairing separation enabled

run Ascent.

will launch your vehicle into an orbit with default altitude and inclination, fairing separation disabled

 

CircToAp and CircToPe

Circularizes the orbit by performing a burn in apoapsis/periapsis to raise periapsis/apoapsis to the same altitude.

 

Launch

Runs Countdown, Liftoff, Ascent and CircToAp in a required order. This script can be launched in flight – it will continue the flight from the point the vehicle is currently in (it skips the countdown by default, but if you set CheckForMovement in Countdown file to false, uLaunch will perform a countdown even in flight). When running this script, you can choose fairing separation, orbit altitude and relative inclination – the same as for Ascent.

 

Landing

Performs a landing burn to land soflty on the surface. It should work fine for most landers, but if you need to tweak your landing burn, you can input parameters:

run Landing(PreTouchdownAltitude,ThrottleLevel,LandingVelocity).

By default they are set to 30 m, 0.8 (80%) and 5 m/s. PreTouchdownAltitude is the altitude on which the lander stops slowing down and starts descending with LandingVelocity.

 

ChangeAp and ChangePe

Change apoapsis/periapsis of the orbit to a set value. Desired apsis altitude can be set as a parameter (in km):

run ChangeAp(TargetApKm).

run ChangePe(TargetPeKm).

 

SHohmann

Performs a simple Hohmann transfer. Desired apsis altitude can be set as parameters (in km) in any order:

run SHohmann(Altitide1Km,Altitude2Km).

 

Intercept

Enters an intercepr trajectory to a target body. Desired flyby periapsis can be set as a parameter (in km):

run Intercept(TargetPeriapsisKm).

 

Eject

Enters an ejection burn to espace body's sphere of influence and reach a desired altitude (higher or lower) of a body it is rotating around. Desired apoapsis or periapsis can be set as a parameter (in km):

run Eject(TargetAltitudeKm).

Example: your ship is in orbit around the Mun. You enter:

run Eject(100).

The script runs a ejection burn and lowers your periapsis above Kerbin to 100 km.

 

ExeNode

Executes next maneuver node.

 

Changelog

Spoiler

 

  • 1.0.0 – 10 June 2020 – Initial release
  • 1.0.0.1 – 10 June 2020
    • Added a license
  • 1.0.1 – 10 June 2020
    • Added default parameters for uAscent and derivatives (75 km orbit altitude, 0 degrees inclination). Now to fly with default parameters you have to run the script without entering any parameters
    • Added automatic time warp for uAscent (after cutoff) and uCircularization (during the coast to apoapsis)
    • Changed minor mistakes
  • 1.0.2 – 11 June 2020
    • Added uLanding
    • Renamed uCircularization to uCirc
    • Locked roll in uAscent
    • Minor optimizations
  • 1.0.2.1 – 12 June 2020
    • Fixed uCirc

 

  • 1.1 – 16 June 2020 – Orbital Flight Update
    • Added uChangeAp
    • Added uChangePe
    • Added uSHohmann
    • Renamed uCirc to uCircToAp
    • Added uCircToPe
    • Added uChangeInc
    • Added uIntercept
    • Added uEject
    • Added uExeNode
    • Removed uAscentFairing and added fairing check to uAscent
    • Added parallel staging support
    • Renamed uFullLaunch to uLaunch
    • Added info readouts
    • Added splashdown check to uLanding
    • Added staging to all scripts with burns
    • Minor improvements
  • 1.1.0.1 – 17 June 2020
    • Important fixes
  • 1.1.1  19 June 2020
    • Added dir.ks file to simplify command running
    • Renamed every script (took away "u" at the beginning)
    • Removed uCounddownLiftoff
    • Added readouts of time to apoapsis and periapsis to some scripts

 

 

 

Future goals

Spoiler

 

  • Scripts for a rendezvous and docking with another spacecraft
  • Advanced scripts for landing (boost to landing zone, descent from orbit, landing at specific coordinates etc.)
  • Advanced scripts for orbital transfers
  • More advanced math and code
  • Documentation

 

Edited by bodryxon
Link to comment
Share on other sites

1.0.2.1 Update - IMPORTANT UPDATE

  • FIxed uCirc

Apparently when changing some numbers to kOS functions in uCirc I deleted a wrong bracket and broke all the maths. Now I fixed it

Edited by bodryxon
Link to comment
Share on other sites

1.1 - ORBITAL FLIGHT UPDATE

A massive update which adds scripts for orbital transfers and improves existing scripts

  • Added uChangeAp
  • Added uChangePe
  • Added uSHohmann
  • Renamed uCirc to uCircToAp
  • Added uCircToPe
  • Added uChangeInc
  • Added uIntercept
  • Added uEject
  • Added uExeNode
  • Removed uAscentFairing and added fairing check to uAscent
  • Added parallel staging support
  • Renamed uFullLaunch to uLaunch
  • Added info readouts
  • Added splashdown check to uLanding
  • Added staging to all scripts with burns
  • Minor improvements

Next major update will be themed around landings

Edited by bodryxon
Link to comment
Share on other sites

1.1.1 Update

  • Added dir.ks file to simplify command running
  • Renamed every script (took away "u" at the beginning)
  • Removed uCounddownLiftoff
  • Added readouts of time to apoapsis and periapsis to some scripts
Edited by bodryxon
Link to comment
Share on other sites

2 hours ago, DY_ZBX said:

I look forward to the day when the spot landing code is born.

I'll be quite busy for the next two weeks or so, but after that I'm going to work on some scripts for spot landing. Boostback script is already done and it works quite well, but with precision of ~1 km. I want to rewrite it so it boosts a lander/stage to wherever the landing zone is, not only retrograde, and add some atmospheric steering for more precision

Link to comment
Share on other sites

  • 1 month later...
  • 3 months later...
  • 2 weeks later...

Thanks for the scripts.. 

FYI, Might be good to check for available engines in the Landing script..  With no engines activated.. it throws an error.   

 

Tried to push Infinity into the stack.
At Archive:/spacecore/landing, line 28

 

Link to comment
Share on other sites

  • 2 years later...
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...