Getting Started#
This guide sets up the kRPC for KSA server, and runs a Python script that reads telemetry from the game.
The Server Mod#
Installation#
The server is a code mod, which runs in the game through StarMap, the KSA code mod loader:
Install StarMap 0.4.8.
Copy the
kRPC.KSAfolder from the release archive into the KSA mods folder,<Documents>/My Games/Kitten Space Agency/mods.Enable the mod in
<Documents>/My Games/Kitten Space Agency/manifest.toml:[[mods]] id = "kRPC.KSA" enabled = true
Launch the game through StarMap.
The server starts once the game has loaded its mods. It listens on 127.0.0.1, with RPC
port 50000 and stream port 50001, and accepts every connection.
Configuration#
The settings are in kRPC.KSA/settings.toml:
auto_start = true
auto_accept_connections = true
[[servers]]
name = "Default Server"
protocol = "ProtocolBuffersOverTCP"
address = "127.0.0.1"
rpc_port = 50000
stream_port = 50001
Set address to 0.0.0.0 to accept connections from other machines.
The Python Client#
Installation#
Install the kRPC Python client from PyPI:
pip install krpc==0.7.0
Your First Script#
This script connects to the game, and prints the bodies of the system and the active vehicle:
conn = krpc.connect(name="KSA telemetry")
ksa = conn.ksa
print(f"Bodies: {', '.join(sorted(ksa.bodies))}")
vehicle = ksa.active_vehicle
print(f"Active vehicle: {vehicle.name} ({vehicle.situation})")
The client builds the KSA service from the definitions the server sends when it connects,
so the service is conn.ksa. The complete script, telemetry.py, goes on to print the vehicle’s altitude, apoapsis and attitude once a
second.
Next Steps#
The Tutorials walk through complete scripts, from Launching into Orbit to planning and executing burns.
The User Guides describe how the server and the game behave. Server side functions run your code inside the game, for events and streams computed there.
The Clients pages cover each client language, and the API reference.