elite

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2023 License: MIT Imports: 12 Imported by: 1

README

elite

GoDoc reference

Go API for Elite Dangerous

Description

This API can be used to extract data from Elite Dangerous while the game is running. The data is obtained from the journal files written by the game, and therefore is only limited by what those files provide.

At the moment that includes things like:

  • The status of many ship properties, such as night vision, landing gear, headlights, and many more.
  • The current star system.
  • Information about the ship, such as hull, shields, jump range, and modules.
  • Players stats regarding things like combat, mining, exploration, and trading.

For a more complete picture of what can be obtained from the API, see the documentation.

Motivation

I wrote this API in order to pass the data to a custom controller that I'm making for the game. I kept it as a separate package so that it could be consumed by anybody that might find the data useful. I think it could also be useful for a dashboard-type project, and in fact, the controller will have a display on it that will provide some of the info supplied by this API.

Installation

go get github.com/BenJuan26/elite

Example Usage

import (
    "fmt"

    "github.com/BenJuan26/elite"
)

func main() {
    system, _ := elite.GetStarSystem()
    fmt.Println("Current star system is " + system)

    status, _ := elite.GetStatus()
    if status.Flags.Docked {
        fmt.Println("Ship is docked")
    } else {
        fmt.Println("Ship is not docked")
    }
}

Documentation

Overview

Package elite provides real-time data from Elite Dangerous through files written to disk by the game.

Example
package main

import (
	"fmt"

	"github.com/BenJuan26/elite"
)

func main() {
	// Errors not handled here
	system, _ := elite.GetStarSystem()
	fmt.Println("Current star system is " + system)

	status, _ := elite.GetStatus()
	if status.Flags.Docked {
		fmt.Println("Ship is docked")
	} else {
		fmt.Println("Ship is not docked")
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStarSystem

func GetStarSystem() (string, error)

GetStarSystem returns the current star system.

func GetStarSystemFromPath

func GetStarSystemFromPath(logPath string) (string, error)

GetStarSystemFromPath returns the current star system using the specified log path.

Types

type Fuel

type Fuel struct {
	Main      float64 `json:"FuelMain"`
	Reservoir float64 `json:"FuelReservoir"`
}

Fuel contains fuel readouts for the ship.

type JournalEntry

type JournalEntry struct {
	Timestamp string `json:"timestamp"`
	Event     string `json:"event"`
}

JournalEntry is a minimal entry in the Journal file. It is primarily intended for embedding within event types, such as StarSystemEvent.

type Loadout

type Loadout struct {
	*JournalEntry
	Ship          string           `json:"Ship"`
	ShipID        int64            `json:"ShipID"`
	ShipName      string           `json:"ShipName"`
	ShipIdent     string           `json:"ShipIdent"`
	HullValue     int64            `json:"HullValue"`
	ModulesValue  int64            `json:"ModulesValue"`
	HullHealth    int64            `json:"HullHealth"`
	UnladenMass   float64          `json:"UnladenMass"`
	CargoCapacity int64            `json:"CargoCapacity"`
	MaxJumpRange  float64          `json:"MaxJumpRange"`
	FuelCapacity  loadout.Fuel     `json:"FuelCapacity"`
	Rebuy         int64            `json:"Rebuy"`
	Modules       []loadout.Module `json:"Modules"`
}

Loadout contains information about the player's ship, its status, and its modules.

func GetLoadout

func GetLoadout() (*Loadout, error)

GetLoadout reads the current ship loadout from the journal files. It will read them from the default log path, which is the Saved Games folder. The full path is:

C:/Users/<Username>/Saved Games/Frontier Developments/Elite Dangerous

If that path is not suitable, use GetLoadoutFromPath.

func GetLoadoutFromPath

func GetLoadoutFromPath(logPath string) (*Loadout, error)

GetLoadoutFromPath reads the current ship loadout from the journal files at the specified path.

type StarSystemEvent

type StarSystemEvent struct {
	*JournalEntry
	StarSystem string `json:"StarSystem,omitempty"`
}

StarSystemEvent is an event that contains the current star system. It may be a Location, FSDJump, or SupercruiseExit event.

type Statistics

type Statistics struct {
	*JournalEntry
	BankAccount     stats.BankAccount     `json:"Bank_Account"`
	Combat          stats.Combat          `json:"Combat"`
	Crime           stats.Crime           `json:"Crime"`
	Smuggling       stats.Smuggling       `json:"Smuggling"`
	Trading         stats.Trading         `json:"Trading"`
	Mining          stats.Mining          `json:"Mining"`
	Exploration     stats.Exploration     `json:"Exploration"`
	Passengers      stats.Passengers      `json:"Passengers"`
	SearchAndRescue stats.SearchAndRescue `json:"Search_And_Rescue"`
	Crafting        stats.Crafting        `json:"Crafting"`
	// Crew            stats.Crew            `json:"Crew"`
	Multicrew      stats.Multicrew      `json:"Multicrew"`
	MaterialTrader stats.MaterialTrader `json:"Material_Trader_Stats"`
}

Statistics is the main statistics object. The statistics are divided into different categories contains by several fields.

func GetStatistics

func GetStatistics() (*Statistics, error)

GetStatistics reads the game statistics from the journal files. It will read them from the default log path, which is the Saved Games folder. The full path is:

C:/Users/<Username>/Saved Games/Frontier Developments/Elite Dangerous

If that path is not suitable, use GetStatisticsFromPath.

func GetStatisticsFromPath

func GetStatisticsFromPath(logPath string) (*Statistics, error)

GetStatisticsFromPath returns game statistics using the specified log path.

type Status

type Status struct {
	Timestamp string      `json:"timestamp"`
	Event     string      `json:"event"`
	Flags     StatusFlags `json:"-"`
	RawFlags  uint32      `json:"Flags"`
	Pips      [3]int32    `json:"Pips"`
	FireGroup int32       `json:"FireGroup"`
	GuiFocus  int32       `json:"GuiFocus"`
	Fuel      Fuel        `json:"Fuel"`
	Cargo     float64     `json:"Cargo"`
	Latitude  float64     `json:"Latitude,omitempty"`
	Longitude float64     `json:"Longitude,omitempty"`
	Heading   int32       `json:"Heading,omitempty"`
	Altitude  int32       `json:"Altitude,omitempty"`
}

Status represents the current state of the player and ship.

func GetStatus

func GetStatus() (*Status, error)

GetStatus reads the current player and ship status from Status.json. It will read them from the default log path, which is the Saved Games folder. The full path is:

C:/Users/<Username>/Saved Games/Frontier Developments/Elite Dangerous

If that path is not suitable, use GetStatusFromPath.

func GetStatusFromBytes

func GetStatusFromBytes(content []byte) (*Status, error)

GetStatusFromBytes reads the current player and ship status from the string contained in the byte array.

func GetStatusFromPath

func GetStatusFromPath(logPath string) (*Status, error)

GetStatusFromPath reads the current player and ship status from Status.json at the specified log path.

func (*Status) ExpandFlags

func (status *Status) ExpandFlags()

ExpandFlags parses the RawFlags and sets the Flags values accordingly.

type StatusFlags

type StatusFlags struct {
	Docked                    bool
	Landed                    bool
	LandingGearDown           bool
	ShieldsUp                 bool
	Supercruise               bool
	FlightAssistOff           bool
	HardpointsDeployed        bool
	InWing                    bool
	LightsOn                  bool
	CargoScoopDeployed        bool
	SilentRunning             bool
	ScoopingFuel              bool
	SRVHandbrake              bool
	SRVTurret                 bool
	SRVUnderShip              bool
	SRVDriveAssist            bool
	FSDMassLocked             bool
	FSDCharging               bool
	FSDCooldown               bool
	LowFuel                   bool
	Overheating               bool
	HasLatLong                bool
	IsInDanger                bool
	BeingInterdicted          bool
	InMainShip                bool
	InFighter                 bool
	InSRV                     bool
	InAnalysisMode            bool
	NightVision               bool
	AltitudeFromAverageRadius bool
	FSDJump                   bool
	SRVHighBeam               bool
}

StatusFlags contains boolean flags describing the player and ship.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL