kRPC
Control the game from your own scripts, written in Python, C#, C++, C, Java, Lua and more.
- Tools
Description
kRPC lets you control Kitten Space Agency from scripts running outside the game. A server mod inside the game exposes the game's API, and your scripts call it over a network connection, from the same computer or another one.
This Python script launches a rocket straight up, and cuts the engine at 10 km:
import krpc
conn = krpc.connect(name="Launch")
vehicle = conn.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
event = conn.add_event(lambda: flight.mean_altitude > 10000)
with event.condition:
event.wait()
vehicle.control.engine_on = False
Features
- Client libraries for Python, C#, C++, C, Java and Lua, the same ones kRPC uses for Kerbal Space Program
- A gRPC server, to generate a client for many other languages
- APIs covering vehicles, parts, engines, crew, flight data, orbits, burns, reference frames, auto-pilot, and more
- Streams and events, for efficient telemetry and waiting
- Server side functions that run your code inside the game
- APIs for saving and loading, the camera, on-screen messages, and drawing lines and user interface windows in the game
kRPC for KSA is experimental, and its API may change between releases.