entity

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package entity provides a typed Go client for the entity manipulation commands registered by softmod/factop/entity.lua.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Area

type Area struct {
	X1 float64
	Y1 float64
	X2 float64
	Y2 float64
}

Area defines a rectangular search region.

func (Area) String

func (a Area) String() string

type Client

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

Client provides typed methods for each entity-* RCON command.

func New

func New(conn *client.Conn) *Client

New creates an entities Client using the given connection.

func (*Client) Count

func (c *Client) Count(area Area, opts FindOptions) (int, error)

Count returns the number of entities matching the filter in the area.

func (*Client) Create

func (c *Client) Create(pos Position, name, force, direction, surface string) (string, error)

Create places a single entity at the given position. Direction uses Factorio direction names: "north", "south", "east", "west", etc. Pass empty strings for force/direction/surface to use defaults.

func (*Client) Destroy

func (c *Client) Destroy(area Area, opts FindOptions) (string, error)

Destroy removes entities matching the filter in the area.

func (*Client) Find

func (c *Client) Find(area Area, opts FindOptions) ([]Entity, error)

Find returns entities matching the filter in the given area.

type Entity

type Entity struct {
	Name       string  `json:"name"`
	X          float64 `json:"x"`
	Y          float64 `json:"y"`
	UnitNumber uint64  `json:"unit_number"`
}

Entity represents a found entity with its position and unit number.

func Parse

func Parse(s string) ([]Entity, error)

Parse converts the compact entity-find wire format into a slice of Entity. Wire format: name:x:y:unit_number,name:x:y:unit_number,...

type FindOptions

type FindOptions struct {
	Name    string
	Type    string
	Force   string
	Limit   int
	Surface string
}

FindOptions controls filtering for Find and Count operations. Use "_" or empty string to skip a filter field.

type Position

type Position struct {
	X float64
	Y float64
}

Position is a map coordinate.

func (Position) String

func (p Position) String() string

Jump to

Keyboard shortcuts

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