kRPC services for FMRS, OCISLY and MechJeb 2 — three KSP mods with no scriptable interface, made drivable from Python
翻译准备中
正在加载完整 README。
查看完整 README ↗kRPC services for FMRS, OCISLY and Trajectories. Three Kerbal Space Program mods that have no scriptable interface at all, made drivable from Python. Version 2 also adds services of its own (flight control and telemetry, stock utilities, booster catch towers) and needs kRPC 0.7.0: it does not load on kRPC 0.6.x.
📖 Full documentation — every procedure (over 300 members in twelve services), a scripting guide, and search.
import krpc
conn = krpc.connect()
conn.fmrs.armed = True # capture this flight's stages
conn.fmrs.track_parachutes = True # else a chute-only booster is ignored
# ... launch, fly, separate ...
vid = next(iter(conn.fmrs.dropped_vessels))
conn.fmrs.jump_to_vessel(vid) # fly the booster down
booster = conn.space_center.active_vessel
# ... land it ...
conn.fmrs.recover_current()
print(conn.fmrs.recovered_funds()) # 14832.0
conn.fmrs.jump_to_main() # back to the mission
The cameras come back on their own.
kRPC exposes stock KSP beautifully and mod internals not at all. It wraps the game's own
objects, plus the KSPField, KSPEvent and KSPAction members of any PartModule — and
that is the whole of it. A mod whose functionality lives in a static class, a singleton or
a ScenarioModule is simply invisible.
All three mods here are exactly that shape:
KSPEvent, no action group and no key binding. Its jump API is a
public method on a MonoBehaviour that stock kRPC has no way to reach. And the jump is
not a vessel switch — it is a full flight-scene reload, 5 to 20 seconds, in which
everything is destroyed and rebuilt from a save file.GameEvent and uses no DontDestroyOnLoad, so that
reload silently drops every camera it was streaming — and nothing in the game brings
them back.Trajectories.API — which is
exactly the shape kRPC cannot see. It holds the only atmospheric impact prediction in
the game that integrates the stock drag cubes at the vessel's actual attitude, and
stock kRPC has no impact prediction of any kind.This mod reaches all three by reflection, resolved once at load, and reports member by member when something has moved.
Over three hundred remote procedures and properties across twelve services. The full reference is in
docs/API.md; the highlights:
conn.fmrs — arm and disarm; list dropped stages with their separation timestamps,
their batch grouping and their KSP persistentId; jump to a stage and back; replay a
landing from its separation save; revert to launch after a jump, when KSP's own revert is
gone; recover a booster and read what it actually earned in funds, science and contracts;
delete a tracked stage.
conn.ocisly — restore camera streams across a scene reload, automatically and by
default, even when the jump was made by hand with no script running. Give duplicate
Hullcams names that are unique and stable across a reload, so two feeds can never swap.
conn.trajectories — Trajectories' atmospheric impact point as latitude, longitude and
terrain altitude, the seconds until it, the impact velocity; set and clear the mod's
landing target and read the two navball directions it derives from it; read and write the
four-node descent profile, or reset it to retrograde in one call, so the prediction
integrates the attitude you will fly rather than the one you have. A witness, not an
autopilot: the prediction ignores thrust.
conn.bridge — what loaded and why not; an ordered, id-numbered event log so a script
can observe an instant rather than sampling a value; a reflection probe for exploring any
loaded mod from Python.
conn.telemetry and conn.control — the
first observes: one-call samples of every engine and gimbal on the active vessel, direct
engine thrust directions that survive flight-scene reloads, the vessel's dynamics at the
physics rate, by persistentId for a vessel that is not active. The second commands: short,
automatically restored leases for per-engine independent throttle, whole command frames
applied in one physics step. Gimbal deflection is observed in degrees; it is not overwritten
behind KSP's own FixedUpdate. conn.control also carries AttitudeV1, an attitude controller
that runs on the physics step; every one of its options is off until a client switches it on.
conn.stock, conn.ident, conn.discovery — delta-v simulation and the stage table,
staging from the frame loop, landing-leg deployment, the fields and events of part modules in one
call; the identifiers kRPC holds but does not expose (part flightID, vessel persistentId);
read-only introspection of the assemblies and types the game has loaded.
conn.tower and conn.tower_site — booster catch towers: put one on the ground from a
craft, list and read the towers of a game from the Space Center. They are part of the separate,
optional TowerCatch package (the tower's parts, its craft and these two services; see Install): the
bridge holds nothing of the tower.
Requires KSP 1.12.x and kRPC 0.7.0. FMRS, OCISLY
and Trajectories are each optional — install the ones you use, and the
corresponding service reports available = False for the others.
以上为 README 的开头部分。其余内容请阅读原文。 查看完整 README ↗