signatures

Module of common, “general” data formats.

class AsteroidChunkID(index: ~typing.Annotated[int, <draftsman.validators._AndValidator object at 0x7436dd5c7b50>], name: str, *, extra_keys: dict[str, ~typing.Any] | None = None)

An object representing an entry in a chunk filters list in asteroid collectors.

Added in version 3.0.0: (Factorio 2.0)

index : _AndValidator object at 0x7436dd5c7b50>]

Index of the asteroid chunk in the filter UI.

name : str

Name of the asteroid chunk to filter.

class BlueprintInsertPlan(
id,
items: Any = NOTHING,
*,
extra_keys: dict[str, Any] | None = None,
)

An object that represents a set of construction requests for a particular item.

Added in version 3.0.0: (Factorio 2.0)

id : ItemID

The item and quality of that item to request on construction.

items : ItemInventoryPositions

The equipment grids/inventories each item is being requested to.

class CircuitNetworkSelection(
red: bool = True,
green: bool = True,
*,
extra_keys: dict[str, Any] | None = None,
)

A definition of which circuit networks to consider when pulling values for circuit operations.

Can be specified as either:

  • A class instance:

    CircuitNetworkSelection(red=True, green=False)
    
  • A dict:

    {"red": True, "green": False}
    
  • Or a set:

    {"red"}
    
green : bool

Whether or not to pull values from the green circuit wire.

red : bool

Whether or not to pull values from the red circuit wire.

class Color(
r: float,
g: float,
b: float,
a: float | None = None,
*,
extra_keys: dict[str, Any] | None = None,
)

A object representing a RGBA color.

The value of each attribute (according to Factorio spec) can be either in the range of [0.0, 1.0] or [0, 255]; if all the numbers are <= 1.0, the former range is used, and the latter otherwise. If “a” is omitted, it defaults to 1.0 or 255 when imported, depending on the range of the other numbers.

class Condition(
first_signal: ~typing.Any | None = None,
comparator='<',
constant: ~typing.Annotated[int,
<draftsman.validators._AndValidator object at 0x7436dd7a8490>] = 0,
second_signal: ~typing.Any | None = None,
*,
extra_keys: dict[str,
~typing.Any] | None = None,
)

A “simple” condition object, used for all logistic conditions as well as almost all circuit conditions. The only circuit condition case that does not use this object is DeciderCombinator.Condition.

comparator : Literal['>', '<', '=', '==', '≥', '>=', '≤', '<=', '≠', '!=']

The comparison operation to perform

constant : _AndValidator object at 0x7436dd7a8490>]

The constant value in the rightmost slot of the condition. Occupies the same spot as second_signal. If both are specified, this value is overridden.

first_signal : SignalID | None

The signal in the leftmost slot of the condition.

second_signal : SignalID | None

The signal in the rightmost slot of the condition. Occupies the same spot as constant. If both are specified, this value takes precedence.

class EntityFilter(name: ~typing.Annotated[str, <function conditional.<locals>.decorator.<locals>.attr_validator at 0x7436d8935ea0>], index: ~typing.Annotated[int, <draftsman.validators._AndValidator object at 0x7436dd5c5ba0>] | None = None, quality: ~typing.Literal['normal', 'uncommon', 'rare', 'epic', 'legendary', 'quality-unknown'] = 'normal', comparator='=', *, extra_keys: dict[str, ~typing.Any] | None = None)

A object representing a filter of a particular entity with a quality or a range of qualities.

comparator : Literal['>', '<', '=', '==', '≥', '>=', '≤', '<=', '≠', '!=']

Comparison operator to use when deducing the range of qualities to select.

Added in version 3.0.0: (Factorio 2.0)

index : _AndValidator object at 0x7436dd5c5ba0>] | None

Position of the filter in the GUI.

name : attr_validator at 0x7436d8935ea0>]

Name of the entity.

quality : Literal['normal', 'uncommon', 'rare', 'epic', 'legendary', 'quality-unknown']

Quality flag of the entity. Defaults to special “any” quality signal if not specified.

Added in version 3.0.0: (Factorio 2.0)

class EquipmentComponent(
equipment,
position,
*,
extra_keys: dict[str, Any] | None = None,
)

An object representing a piece of equipment and it’s location in an attached equipment grid.

Added in version 3.0.0: (Factorio 2.0)

equipment : EquipmentID

The type of equipment to add.

position : Vector

The integer coordinate of the top leftmost tile in which this item sits.

class EquipmentID(
name: str,
quality: 'normal' | 'uncommon' | 'rare' | 'epic' | 'legendary' | 'quality-unknown' = 'normal',
*,
extra_keys: dict[str, Any] | None = None,
)

An object representing a particular type of equipment.

Added in version 3.0.0: (Factorio 2.0)

name : str

The name of the equipment.

quality : Literal['normal', 'uncommon', 'rare', 'epic', 'legendary', 'quality-unknown']

The quality of the quipment

class IDParameter(
type: 'id',
id: str,
name: str = '',
quality_condition: Any = NOTHING,
ingredient_of: str | None = None,
parameter: bool = True,
*,
extra_keys: dict[str, Any] | None = None,
)

A blueprint parameter specification representing a signal ID substitution.

Added in version 3.1.0: (Factorio 2.0)

id : str

The name of the specific signal ID. Can be either a fixed signal name (in which case parameter should be False) or a parameter ID (in which case parameter should be True). Only used if type is "id".

ingredient_of : str | None

A separate parameter name to use as a basis for determining the value of this parameter’s signal type.

name : str

The user-given display name to this particular parameter.

parameter : bool

Whether or not this parameter should be selected during placement, or if it should just act as a variable for use via other parameters.

quality_condition : QualityFilter

The condition indicating what quality to select. Appears to only permit a exactly equals comparison.

type : Literal['id']

The type of this parameter, indicating this parameters structure.

class Icon(index: ~typing.Annotated[int, <draftsman.validators._AndValidator object at 0x7436dd5c5990>, ~OneIndexed], signal: ~typing.Any, *, extra_keys: dict[str, ~typing.Any] | None = None)

A visual icon used for all Blueprintable classes.

index : _AndValidator object at 0x7436dd5c5990>, ~OneIndexed]

Numeric index of the icon.

signal : SignalID

Which signal icon to display.

class Inventory(
filters=NOTHING,
bar: ~typing.Annotated[int,
<draftsman.validators._AndValidator object at 0x7436dd5c5660>] | None = None,
*,
extra_keys: dict[str,
~typing.Any] | None = None,
)

An object which represents an inventory - stores metadata related to it’s internal size, and allows to set it’s filters and limiting bar all in one place.

Note

On certain entities, setting some of these attributes will have no on the serialized output. Consult each entity attribute for details.

bar : _AndValidator object at 0x7436dd5c5660>] | None

The limiting bar of the inventory. Used to prevent a the final-most slots in the inventory from accepting items.

Raises IndexWarning if the set value exceeds the Entity’s inventory_size attribute.

filters : list[ItemFilter]

The list of filters applied to this entity’s inventory slots.

property size : _AndValidator object at 0x7436dd5c5660>] | None

The number of inventory slots that this Entity has. Equivalent to the "inventory_size" key in Factorio’s data.raw. Returns None if this entity’s name is not recognized by Draftsman.

set_filter(
index: int,
item: str | None,
quality: 'normal' | 'uncommon' | 'rare' | 'epic' | 'legendary' | 'quality-unknown' = 'normal',
comparator: '>' | '<' | '=' | '==' | '≥' | '>=' | '≤' | '<=' | '≠' | '!=' = '=',
)

Sets the item filter at a particular index. If item is set to None, the item filter at that location is removed.

Parameters:
index: int

The index of the filter to set.

item: str | None

The string name of the item to filter, or None to clear the filter at index.

Raises:
  • TypeError – If index is not an int or if item is neither a str nor None.

  • InvalidItemError – If item is not a valid item name.

  • IndexError – If index lies outside the range [0, inventory_size).

class InventoryPosition(inventory, stack: ~typing.Annotated[int, <draftsman.validators._AndValidator object at 0x7436dd5c7b50>], count: ~typing.Annotated[int, <draftsman.validators._AndValidator object at 0x7436dd5c7b50>] | None = 1, *, extra_keys: dict[str, ~typing.Any] | None = None)

An object which represents a particular inventory slot inside of an entity.

Added in version 3.0.0: (Factorio 2.0)

count : _AndValidator object at 0x7436dd5c7b50>] | None

The amount of the item to request to that slot. Defaults to 1 if omitted.

inventory : InventoryType

Which inventory this item sits in. As of Factorio 2.0, entities can have multiple internal inventories which can be separately delivered to, such as inputs, outputs, ammo storage, trash slots, etc.

stack : _AndValidator object at 0x7436dd5c7b50>]

Which slot in the inventory this item sits in.

class ItemFilter(index: ~typing.Annotated[int, <draftsman.validators._AndValidator object at 0x7436dd7a8fd0>, ~OneIndexed], name: ~typing.Annotated[str, <function conditional.<locals>.decorator.<locals>.attr_validator at 0x7436d8935c60>], quality: ~typing.Literal[None, 'normal', 'uncommon', 'rare', 'epic', 'legendary', 'quality-unknown'] = 'normal', comparator='=', *, extra_keys: dict[str, ~typing.Any] | None = None)

A object representing a particular item with a quality or a range of qualities, used for things like Inserter.filters.

comparator : Literal['>', '<', '=', '==', '≥', '>=', '≤', '<=', '≠', '!=']

Comparator if filtering a range of multiple qualities.

Added in version 3.0.0: (Factorio 2.0)

index : _AndValidator object at 0x7436dd7a8fd0>, ~OneIndexed]

Index of the filter in the GUI.

name : attr_validator at 0x7436d8935c60>]

Name of the item.

quality : Literal[None, 'normal', 'uncommon', 'rare', 'epic', 'legendary', 'quality-unknown']

Quality flag of the item.

Added in version 3.0.0: (Factorio 2.0)

class ItemID(name: ~typing.Annotated[str, <function conditional.<locals>.decorator.<locals>.attr_validator at 0x7436d8935c60>], quality: ~typing.Literal['normal', 'uncommon', 'rare', 'epic', 'legendary', 'quality-unknown'] = 'normal', *, extra_keys: dict[str, ~typing.Any] | None = None)

An object representing a particular item. Used by BlueprintInsertPlan.id.

Added in version 3.0.0: (Factorio 2.0)

name : attr_validator at 0x7436d8935c60>]

The name of the item.

quality : Literal['normal', 'uncommon', 'rare', 'epic', 'legendary', 'quality-unknown']

The quality of the item.

class ItemInventoryPositions(
in_inventory=NOTHING,
grid_count: ~typing.Annotated[int,
<draftsman.validators._AndValidator object at 0x7436dd5c7b50>] = 0,
*,
extra_keys: dict[str,
~typing.Any] | None = None,
)

An object which holds a list of all positions an item should be requested to inside of an entity, as well as a count of how many of that item exist in an attached equipment grid.

Added in version 3.0.0: (Factorio 2.0)

grid_count : _AndValidator object at 0x7436dd5c7b50>]

The total amount of this item being requested to the attached equipment grid, if applicable. Always zero if the entity has no equipment grid to request to.

The positions of the item in the equipment grid is defined elsewhere in the equipment attribute.

in_inventory : list[InventoryPosition]

The list of all unique InventoryPosition s that the item should go.

class ManualSection(index: ~typing.Annotated[int, <draftsman.validators._AndValidator object at 0x7436dd7a8fd0>, ~OneIndexed], filters: list[~typing.Any] = NOTHING, group='', active: bool = True, *, extra_keys: dict[str, ~typing.Any] | None = None)

A “manually” (player) defined collection of signals, typically used for logistic request sections as well as constant combinator signal groups.

Added in version 3.0.0: (Factorio 2.0)

active : bool

Whether or not this logistic section is currently enabled and contributing it’s output.

filters : dict[int, SignalFilter]

List of item requests for this section.

group : str

Name of this section group. Once named, this group will become registered within the save it is imported into. If a logistic section with the given name already exists within the save, the one that exists in the save will overwrite any sections more recently specified.

index : _AndValidator object at 0x7436dd7a8fd0>, ~OneIndexed]

Location of the logistics section within the entity. Hard capped to 100 sections per entity.

get_signal(index: int) SignalFilter | None

Get the SignalFilter entry at a particular index, if it exists.

Parameters:
index: int

The index of the signal to analyze.

Returns:

A SignalFilter instance, or None if nothing was found at that index.

set_signal(
index: int,
name: str | None,
count: int = 0,
quality: 'normal' | 'uncommon' | 'rare' | 'epic' | 'legendary' | 'quality-unknown' = 'normal',
type: str | None = None,
) None

Sets the particular signal at any given point.

Parameters:
index: int

The index of the signal in the GUI.

name: str | None

The name of the signal.

count: int = 0

The amount of the item/the value to output.

quality: 'normal' | 'uncommon' | 'rare' | 'epic' | 'legendary' | 'quality-unknown' = 'normal'

The quality of the signal.

type: str | None = None

The internal type of the signal.

class NumberParameter(
type: 'number',
number: str,
not_parametrised: bool = False,
name: str = '',
variable: str = '',
formula: str = '',
dependent: bool = False,
*,
extra_keys: dict[str, Any] | None = None,
)

A blueprint parameter specification representing a numeric value substitution.

Added in version 3.1.0: (Factorio 2.0)

dependent : bool

Whether or not this parameter is dependent on other variables/formulas above it in order to determine it’s value.

formula : str

A string representing a mathematical sequence in order to calculate the replacement value of this parameter, optionally using previously defined variable names.

name : str

The user-given display name to this particular parameter.

not_parametrised : bool

Whether or not this value should be substitued, or left as-is in the original blueprint.

number : str

A string representing the constant number value to search for and substitute.

type : Literal['number']

The type of this parameter, indicating this parameters structure.

variable : str

A string representing a variable name that can be reused in subsequent formula definitions.

class Parameter(*, extra_keys: dict[str, Any] | None = None)
class QualityFilter(
quality: None | 'normal' | 'uncommon' | 'rare' | 'epic' | 'legendary' | 'quality-unknown' | None = None,
comparator='=',
*,
extra_keys: dict[str, Any] | None = None,
)

An object used to select particular qualities; used by SelectorCombinator.quality_filter.

Added in version 3.0.0: (Factorio 2.0)

comparator : Literal['>', '<', '=', '==', '≥', '>=', '≤', '<=', '≠', '!=']

The comparison operation to perform.

quality : Literal[None, 'normal', 'uncommon', 'rare', 'epic', 'legendary', 'quality-unknown']

The signal quality to compare against.

class SignalFilter(index: ~typing.Annotated[int, <draftsman.validators._AndValidator object at 0x7436dd7a8fd0>, ~OneIndexed], name: ~typing.Annotated[str, <function conditional.<locals>.decorator.<locals>.attr_validator at 0x7436d8935d80>] | None, count: ~typing.Annotated[int, <draftsman.validators._AndValidator object at 0x7436dd7a8490>] | None, type: ~typing.Literal['virtual', 'item', 'fluid', 'recipe', 'entity', 'space-location', 'asteroid-chunk', 'quality'] | None = NOTHING, quality: ~typing.Literal[None, 'normal', 'uncommon', 'rare', 'epic', 'legendary', 'quality-unknown'] | None = None, comparator='=', max_count: ~typing.Annotated[int, <draftsman.validators._AndValidator object at 0x7436dd7a8490>] | None = None, *, extra_keys: dict[str, ~typing.Any] | None = None)

An object that specifies a single signal or a range of signal types. Used as filters for logistics requests, as well as the signal specifications inside of ConstantCombinator.

comparator : Literal['>', '<', '=', '==', '≥', '>=', '≤', '<=', '≠', '!=']

Comparison operator when deducing the quality type.

Added in version 3.0.0: (Factorio 2.0)

count : _AndValidator object at 0x7436dd7a8490>] | None

Value of the signal filter, or the lower bound of a range if max_count is also specified.

index : _AndValidator object at 0x7436dd7a8fd0>, ~OneIndexed]

Numeric index of the signal in the combinator. Typically the index of the signal in the parent ‘filters’ key, but this is not strictly enforced.

max_count : _AndValidator object at 0x7436dd7a8490>] | None

The maximum amount of the signal to request of the signal to emit. Only used (currently) with logistics-type requests.

Added in version 3.0.0: (Factorio 2.0)

name : attr_validator at 0x7436d8935d80>] | None

Name of the signal.

quality : Literal[None, 'normal', 'uncommon', 'rare', 'epic', 'legendary', 'quality-unknown']

Quality flag of the signal. Defaults to special “any” quality signal if not specified.

Added in version 3.0.0: (Factorio 2.0)

type : Literal['virtual', 'item', 'fluid', 'recipe', 'entity', 'space-location', 'asteroid-chunk', 'quality'] | None

Type of the signal.

Added in version 3.0.0: (Factorio 2.0)

class SignalID(
name: ~typing.Annotated[str,
<function conditional.<locals>.decorator.<locals>.attr_validator at 0x7436d8935d80>] | None = None,
type: ~typing.Literal['virtual',
'item',
'fluid',
'recipe',
'entity',
'space-location',
'asteroid-chunk',
'quality'] = NOTHING,
quality: ~typing.Literal['normal',
'uncommon',
'rare',
'epic',
'legendary',
'quality-unknown'] | None = 'normal',
comparator: ~typing.Literal['>',
'<',
'=',
'==',
'≥',
'>=',
'≤',
'<=',
'≠',
'!='] | None = '=',
*,
extra_keys: dict[str,
~typing.Any] | None = None,
)

A signal ID, composed of a name, a signal type, and an optional quality.

For convenience, a SignalID object can be constructed with just the string name, if the current Draftsman environment recognizes the name:

>>> some_signal = SignalID("iron-ore")
>>> some_signal.name
'iron-ore'
>>> some_signal.type
'item'
>>> some_signal.quality
'normal'

In certain cases, you can even omit the SignalID constructor entirely in obvious cases:

>>> condition = Condition()
>>> condition.first_signal = "iron-ore"

>>> assert type(condition.first_signal) is SignalID
>>> assert condition.first_signal.name == "iron-ore"
>>> assert condition.first_signal.type == "item"
>>> assert condition.first_signal.quality == "normal"

Because the name "iron-ore" is known, Draftsman can pick a correct type for it. For most applications, this defaults to "item", but notable exceptions include fluids ("fluid") and virtual signals ("virtual"):

>>> SignalID("iron-ore").type
"item"
>>> SignalID("steam").type
"fluid"
>>> SignalID("signal-A").type
"virtual"

In Factorio 2.0 and up, multiple SignalID’s can share the same name but have different types. The default signal type is the first entry in the return result of get_valid_types(), which in most circumstances is usually "item". If you want a different type than the default, it must be manually specified using the constructor:

SignalID("assembling-machine") # type="item"
SignalID("assembling-machine", type="entity")
SignalID("assembling-machine", type="recipe")

If the name is not recognized by the current environment, the type will default back to “item”, along with an accompanying warning message:

>>> SignalID("who knows!")
%%%: UnknownSignalWarning: Unknown signal 'who knows!'; did you mean 'space-location-unknown'?
...
SignalID(name='who knows!', type='item', quality='normal')
comparator : Literal['>', '<', '=', '==', '≥', '>=', '≤', '<=', '≠', '!='] | None

Comparator used when representing quality ranges. A value of None is only permitted when quality is also None.

name : attr_validator at 0x7436d8935d80>] | None

Name of the signal. If omitted, the signal is treated as either no signal or any signal.

quality : Literal['normal', 'uncommon', 'rare', 'epic', 'legendary', 'quality-unknown'] | None

Quality flag of the signal. A quality of None means any quality.

type : Literal['virtual', 'item', 'fluid', 'recipe', 'entity', 'space-location', 'asteroid-chunk', 'quality']

Category of the signal.

classmethod converter(value: Any) SignalID

Attempt to convert an input string name into a SignalID representation. Raises a ValueError if unable to determine the type of a signal’s name, likely if the signal is misspelled or used in a modded configuration that differs from Draftsman’s current one.

class SignalIDBase(
name: ~typing.Annotated[str,
<function conditional.<locals>.decorator.<locals>.attr_validator at 0x7436d8935d80>] | None = None,
type: ~typing.Literal['virtual',
'item',
'fluid',
'recipe',
'entity',
'space-location',
'asteroid-chunk',
'quality'] = NOTHING,
*,
extra_keys: dict[str,
~typing.Any] | None = None,
)

A SignalID but without any quality definition. Used by SelectorCombinator.

Added in version 3.0.0: (Factorio 2.0)

name : attr_validator at 0x7436d8935d80>] | None

Name of the signal. If omitted, the signal is treated as no signal and removed on import/export cycle.

type : Literal['virtual', 'item', 'fluid', 'recipe', 'entity', 'space-location', 'asteroid-chunk', 'quality']

Category of the signal.

class StockConnection(
stock,
front=None,
back=None,
*,
extra_keys: dict[str, Any] | None = None,
)

A structure representing a train coupling between wagons.

Added in version 3.0.0: (Factorio 2.0)

back : Association | None

What rolling stock is connected at the back of stock.

front : Association | None

What rolling stock is connected at the front of stock.

stock : Association

What rolling stock’s connections are being defined.

class TargetID(index: ~typing.Annotated[int, <draftsman.validators._AndValidator object at 0x7436dd5c7b50>], name: str, *, extra_keys: dict[str, ~typing.Any] | None = None)

An object representing an entry in a target priorities list in turrets.

Added in version 3.0.0: (Factorio 2.0)

index : _AndValidator object at 0x7436dd5c7b50>]

Index of the target in the GUI.

name : str

Name of the target.

class TileFilter(index: ~typing.Annotated[int, <draftsman.validators._AndValidator object at 0x7436dd5c5ba0>] | None, name: ~typing.Annotated[str, <function conditional.<locals>.decorator.<locals>.attr_validator at 0x7436d89360e0>], *, extra_keys: dict[str, ~typing.Any] | None = None)

An object representing the filter of a particular tile.

index : _AndValidator object at 0x7436dd5c5ba0>] | None

Position of the filter in the GUI.

name : attr_validator at 0x7436d89360e0>]

The name of a valid deconstructable tile.