factorio

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package factorio turns typed calls into one-line RCON commands routed through the factorio_mcp companion mod, and decodes the mod's JSON envelope back into Go values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeLuaSingleQuoted

func EscapeLuaSingleQuoted(s string) string

EscapeLuaSingleQuoted escapes s so it can be safely embedded inside a Lua single-quoted string literal. Payloads are always passed inside '...' in the command templates, so only a small, well-defined set of bytes is dangerous: the escape character itself and the closing quote. Control characters are escaped defensively even though JSON-encoded payloads never contain raw ones.

Types

type Client

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

Client is the default Dispatcher, backed by an RCON executor.

func NewClient

func NewClient(exec rcon.Executor) *Client

NewClient wraps an RCON executor in a Dispatcher.

func (*Client) Call

func (c *Client) Call(ctx context.Context, fn string, args any) (json.RawMessage, error)

Call invokes the named mod function with the given arguments and returns the decoded "data" field of the response envelope.

func (*Client) Eval

func (c *Client) Eval(ctx context.Context, lua string) (json.RawMessage, error)

Eval runs raw Lua source through the mod's eval handler. It is a cheat/debug escape hatch; callers gate it behind configuration.

type Dispatcher

type Dispatcher interface {
	Call(ctx context.Context, fn string, args any) (json.RawMessage, error)
	Eval(ctx context.Context, lua string) (json.RawMessage, error)
}

Dispatcher executes named companion-mod functions and evaluates raw Lua.

type ErrLua

type ErrLua struct {
	Code   string
	Detail string
	Raw    string
}

ErrLua reports an error returned by the companion mod (a handler error, a bad request, or non-JSON output from the game engine).

func (*ErrLua) Error

func (e *ErrLua) Error() string

type Position

type Position struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

Position is a map/world coordinate. Factorio uses floating-point tile coordinates with +x east and +y south.

Jump to

Keyboard shortcuts

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