factorio

package
v0.0.0-...-7dff133 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package factorio provides tooling to interact with Factorio files & binary.

Index

Constants

View Source
const (
	// ModsDir is the datadir subdir for mods.
	ModsDir = "mods"
	// SavesDir is the datadir subdirectory for game saves.
	SavesDir = "saves"
)

Variables

This section is empty.

Functions

func EnableMod

func EnableMod(modsPath string, modName string) error

EnableMod activate the named mod in the provided mod directory.

func Encode

func Encode(data []byte) string

Encode data in a format suitable for Factorio `game.decode_string`.

Types

type Factorio

type Factorio struct {
	// contains filtered or unexported fields
}

Factorio offers methods to manipulate a Factorio install.

func New

func New(s *Settings) (*Factorio, error)

New creates a new Factorio instance from the settings.

func (*Factorio) Binary

func (f *Factorio) Binary() string

Binary returns the path to the Factorio binary.

func (*Factorio) CopyMods

func (f *Factorio) CopyMods(dstMods string, filterOut []string) error

CopyMods creates a mods directory in the given location based on the current one. This can serve as a base to forcefully enable a mod or similar.

func (*Factorio) DataDir

func (f *Factorio) DataDir() string

DataDir returns the place where saves, mods and others are located.

func (*Factorio) FindSaveFile

func (f *Factorio) FindSaveFile(name string) (string, error)

FindSaveFile try to find the savegame with the given name. It will look in current directory, in Factorio directory, with and without .zip.

func (*Factorio) ForceVerbose

func (f *Factorio) ForceVerbose()

ForceVerbose set verbose to true.

func (*Factorio) ModsDir

func (f *Factorio) ModsDir() string

ModsDir is the directory where all the mods are located.

func (*Factorio) Run

func (f *Factorio) Run(ctx context.Context, args []string) error

Run factorio.

func (*Factorio) ScriptOutput

func (f *Factorio) ScriptOutput() string

ScriptOutput is the place where mods can write data.

type ModList

type ModList struct {
	Mods []*ModListEntry `json:"mods"`
}

ModList represents the content of `mod-list.json` file in Factorio.

func LoadModList

func LoadModList(filename string) (*ModList, error)

LoadModList reads a mod-list.json file from its filename.

func (*ModList) Enable

func (mlist *ModList) Enable(name string)

Enable marks a given mod as enabled.

func (*ModList) Write

func (mlist *ModList) Write(filename string) error

Write writes the given filename with a serialized version of this modlist.

type ModListEntry

type ModListEntry struct {
	Name    string `json:"name"`
	Enabled bool   `json:"enabled"`
}

ModListEntry is a single mod entry in the `mod-list.json` file.

type Settings

type Settings struct {
	// contains filtered or unexported fields
}

Settings for creating a Factorio helper instance.

func (*Settings) Binary

func (s *Settings) Binary() (string, error)

Binary returns the path to the Factorio binary.

func (*Settings) DataDir

func (s *Settings) DataDir() string

DataDir returns the place where saves, mods and others are located. Returns "" if no directory is found.

func (*Settings) Register

func (s *Settings) Register(flags *pflag.FlagSet, prefix string) *Settings

Register add flags to configure how to call Factorio on the flagset.

func (*Settings) ScriptOutput

func (s *Settings) ScriptOutput() (string, error)

ScriptOutput returns the Factorio script-output directory.

Jump to

Keyboard shortcuts

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