BenChung / KRPC.jl

A kRPC client for Julia
MIT License
3 stars 4 forks source link

KRPC

A Julia wrapper library for the KRPC remote procedure call system for Kerbal Space Program.

Example

Setup:

using KRPC
using KRPC.Interface.SpaceCenter.Helpers

KRPC.kerbal_connect("test", "127.0.0.1") do
    # use the connection
end

Get the vessel's current position:

spaceCenter = KRPC.Interface.SpaceCenter.RemoteTypes.SpaceCenter(conn)
vessel = ActiveVessel(spaceCenter)
body_rf = ReferenceFrame(Body(Orbit(vessel)))
println(Position(vessel, body_rf))

Stream the vessel's current position:

spaceCenter = KRPC.Interface.SpaceCenter.RemoteTypes.SpaceCenter(conn)
vessel = ActiveVessel(spaceCenter)
body_rf = ReferenceFrame(Body(Orbit(vessel)))
add_stream(conn, (KRPC.Interface.SpaceCenter.Vessel_Position(vessel, body_rf), )) do stream
    for (position, ) in stream
        println(position)
    end
end