Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wisq/space_ex
Elixir client library for kRPC, a remote control API for Kerbal Space Program
https://github.com/wisq/space_ex
elixir kerbal-space-program krpc
Last synced: 22 days ago
JSON representation
Elixir client library for kRPC, a remote control API for Kerbal Space Program
- Host: GitHub
- URL: https://github.com/wisq/space_ex
- Owner: wisq
- License: apache-2.0
- Created: 2018-01-11T22:06:08.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-24T03:36:00.000Z (over 1 year ago)
- Last Synced: 2024-03-15T01:54:09.480Z (9 months ago)
- Topics: elixir, kerbal-space-program, krpc
- Language: Elixir
- Homepage:
- Size: 330 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# SpaceEx
SpaceEx is an Elixir client library for [kRPC](https://krpc.github.io/krpc/).
kRPC is a mod for [Kerbal Space Program](https://kerbalspaceprogram.com/), the rocket simulation game.
With kRPC, you can control your rocket using external scripts. With SpaceEx, you can write those external scripts in [Elixir](https://elixir-lang.org/), and enjoy all the wonderful features of the Elixir language and the Erlang VM.
[![Build Status](https://travis-ci.org/wisq/space_ex.svg?branch=master)](https://travis-ci.org/wisq/space_ex)
[![Hex.pm Version](http://img.shields.io/hexpm/v/space_ex.svg?style=flat)](https://hex.pm/packages/space_ex)## Installation
SpaceEx is [available on hex.pm](https://hex.pm/packages/space_ex).
If you haven't already, start a project with `mix new`.
Then, add `space_ex` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:space_ex, "~> 0.8.0"}
]
end
```Run `mix deps.get` to pull SpaceEx into your project, and you're good to go.
## Usage
```elixir
# If your kRPC is on the same machine:
conn = SpaceEx.Connection.connect!()
# If it's on a different one:
# conn = SpaceEx.Connection.connect!(host: "1.2.3.4")vessel = SpaceEx.SpaceCenter.active_vessel(conn)
control = SpaceEx.SpaceCenter.Vessel.control(vessel)SpaceEx.KRPC.set_paused(conn, false)
IO.puts("Burning for 1 second ...")
SpaceEx.SpaceCenter.Control.set_throttle(control, 1.0)
Process.sleep(1_000)
SpaceEx.SpaceCenter.Control.set_throttle(control, 0.0)
IO.puts("Burn complete.")SpaceEx.KRPC.set_paused(conn, true)
```This will connect to your kRPC game, unpause it if needed, burn the engines for one second, and then pause it again.
More examples can be found in the [examples directory](https://github.com/wisq/space_ex/tree/master/examples).
Although this library is very new, the API has mostly stabilised at this point, and I expect to release v1.0.0 within the next few days. For a list of what's planned, see the [to-do list](https://github.com/wisq/space_ex/blob/master/TODO.md).
## Documentation
Full documentation can be found at [https://hexdocs.pm/space_ex](https://hexdocs.pm/space_ex).
## Legal stuff
Copyright © 2018, Adrian Irving-Beer.
SpaceEx is released under the [Apache 2 License](https://github.com/wisq/space_ex/blob/master/LICENSE) and is provided with **no warranty**. But, let's face it — if anything goes wrong, the worst that can likely happen is that your rocket crashes and Jeb dies.
SpaceEx is in no way associated with the launching of real rockets, and has no affiliations with any companies that do real rocketry.