kRPC - Remote Procedure Calls for Kitten Space Agency#

kRPC for KSA lets you control Kitten Space Agency from scripts running outside the game. A server inside the game exposes the game’s API, and the kRPC 0.7.0 client libraries call it from Python, C#, C++, C, Java and Lua.

Note

kRPC for KSA is experimental, and its API may change between releases.

This script launches a rocket from Cape Canaveral straight up, then cuts the engines once it reaches an altitude of 10 km:

import krpc

conn = krpc.connect(name="Launch")
ksa = conn.ksa
vehicle = ksa.launch_vehicle("Rocket", "CCSFS LC-39A")
flight = vehicle.flight

vehicle.auto_pilot.target_pitch_and_heading(90, 90)
vehicle.auto_pilot.engage()
vehicle.control.throttle = 1
vehicle.control.activate_next_sequence()
vehicle.control.engine_on = True
print(f"{vehicle.name} has launched")

event = conn.add_event(lambda: flight.mean_altitude > 10000)
with event.condition:
    event.wait()

vehicle.control.engine_on = False
vehicle.auto_pilot.disengage()
print(f"{vehicle.name} reached 10 km")
Getting Started

Install the server mod, install a client and run your first script.

Getting Started
User Guides

How the server and the game behave: reference frames, object lifetime, the auto-pilot, server side functions and timing.

User Guides
Tutorials

Complete scripts that launch into orbit, plan burns and change orbits.

Tutorials
Clients

The guide and API reference for each client library.

Clients
Developer Guide

Build the mod, its client stubs and its documentation from source, and run the tests.

Developer Guide
kRPC for KSP

The kRPC documentation, for Kerbal Space Program.

https://krpc.github.io/krpc/

Clients#

Python
Python
C#
C#
C++
C++
C-nano
C-nano
Java
Java
Lua
Lua