constants

Enumerations of frequently used constants.

enum BeltReadMode(value)

Determines what manner belts should send their contents as signals.

Member Type:

int

Valid values are as follows:

PULSE = <BeltReadMode.PULSE: 0>

Pulse the signal for one tick when first detected.

HOLD = <BeltReadMode.HOLD: 1>

Hold the signal for as long as the item is present.

HOLD_ALL_BELTS = <BeltReadMode.HOLD_ALL_BELTS: 2>

Hold the signal for all items on all contiguous connected belt segments.

Added in version 3.0.0: (Factorio 2.0)

enum Direction(value)

Factorio direction enum. Encompasses all 16 cardinal directions, diagonals, and half-dagonals in the range [0, 15] where north is 0 and incrementing clockwise. Provides a number of convenience constants and functions over working with a raw int value.

Member Type:

int

Valid values are as follows:

NORTH = <Direction.NORTH: 0>
NORTHNORTHEAST = <Direction.NORTHNORTHEAST: 1>
NORTHEAST = <Direction.NORTHEAST: 2>
EASTNORTHEAST = <Direction.EASTNORTHEAST: 3>
EAST = <Direction.EAST: 4>
EASTSOUTHEAST = <Direction.EASTSOUTHEAST: 5>
SOUTHEAST = <Direction.SOUTHEAST: 6>
SOUTHSOUTHEAST = <Direction.SOUTHSOUTHEAST: 7>
SOUTH = <Direction.SOUTH: 8>
SOUTHSOUTHWEST = <Direction.SOUTHSOUTHWEST: 9>
SOUTHWEST = <Direction.SOUTHWEST: 10>
WESTSOUTHWEST = <Direction.WESTSOUTHWEST: 11>
WEST = <Direction.WEST: 12>
WESTNORTHWEST = <Direction.WESTNORTHWEST: 13>
NORTHWEST = <Direction.NORTHWEST: 14>
NORTHNORTHWEST = <Direction.NORTHNORTHWEST: 15>

The Enum and its members also have the following methods:

opposite() Direction

Returns the direction opposite this one.

>>> Direction.NORTH.opposite()
<Direction.SOUTH: 8>
Returns:

A new Direction.

next(eight_way: bool = False) Direction

Returns the direction one unit clockwise from the current direction. eight_way determines whether or not to treat the next-most direction from a four-way or eight-way perspective; for example:

>>> Direction.NORTH.next(eight_way=False)
<Direction.EAST: 4>
>>> Direction.NORTH.next(eight_way=True)
<Direction.NORTHEAST: 2>
Parameters:
eight_way: bool = False

Whether to increment the current direction by 2 or 4 units.

Returns:

A new Direction object.

previous(eight_way: bool = False) Direction

Returns the direction one unit counter-clockwise from the current direction. eight_way determines whether or not to treat the previous-most direction from a four-way or eight-way perspective; for example:

>>> Direction.NORTH.previous(eight_way=False)
<Direction.WEST: 12>
>>> Direction.NORTH.previous(eight_way=True)
<Direction.NORTHWEST: 14>
Parameters:
eight_way: bool = False

Whether to increment the current direction by 1 or 2 units.

Returns:

A new Direction object.

to_closest_valid_direction(valid_directions) Direction

Floor this direction to the closest valid direction. valid_directions must be exactly one of the constants FOUR_WAY_DIRECTIONS, EIGHT_WAY_DIRECTIONS, or SIXTEEN_WAY_DIRECTIONS.

to_orientation() Orientation

Converts this direction to an Orientation of corresponding value.

>>> Direction.EAST.to_orientation()
<Orientation.EAST: 0.25>
Returns:

An equivalent Orientation object.

to_vector(magnitude: float = 1.0) Vector

Converts a Direction into an equivalent 2-dimensional vector, for various linear operations. Works with both four-way and eight-way directions. Returned vectors are unit-length, unless magnitude is specified.

>>> Direction.NORTH.to_vector(magnitude=2)
Vector(0, -2)
>>> Direction.SOUTHWEST.to_vector()
Vector(-0.7071067811865476, 0.7071067811865476)
Parameters:
magnitude: float = 1.0

The magnitude (total length) of the vector to create.

Returns:

A new Vector object pointing in the correct direction.

to_legacy() LegacyDirection

Converts this Direction to a LegacyDirection.

enum FilterMode(value)

In what manner should this filter be treated.

Member Type:

int

Valid values are as follows:

WHITELIST = <FilterMode.WHITELIST: 0>

Include only the listed items.

BLACKLIST = <FilterMode.BLACKLIST: 1>

Exclude only the listed items.

enum InserterModeOfOperation(value)

Deprecated since version 3.0.0: (Factorio 2.0)

In modern Factorio, each of these operations can be controlled individually as opposed to this “master” mode.

Inserter circuit control constants. Determines how the Entity should behave when connected to a circuit network.

Member Type:

int

Valid values are as follows:

ENABLE_DISABLE = <InserterModeOfOperation.ENABLE_DISABLE: 0>

Turns the inserter on or off depending on the circuit condition.

SET_FILTERS = <InserterModeOfOperation.SET_FILTERS: 1>

Sets the inserter’s filter signals based on read signals.

READ_HAND_CONTENTS = <InserterModeOfOperation.READ_HAND_CONTENTS: 2>

Reads the contents of the inserter’s hand and sends it to the connected wire(s).

NONE = <InserterModeOfOperation.NONE: 3>

Does nothing. Ignores any connected circuit network signal.

SET_STACK_SIZE = <InserterModeOfOperation.SET_STACK_SIZE: 4>

Sets the stack size override to the value of an input signal.

enum InserterReadMode(value)

Determines what manner inserters should send their contents signal.

Member Type:

int

Valid values are as follows:

PULSE = <InserterReadMode.PULSE: 0>

Pulse the signal for one tick when first detected.

HOLD = <InserterReadMode.HOLD: 1>

Hold the signal for as long as the item is present.

enum InventoryType(value)

Constants which define which internal inventories Entity.item_requests should reside in.

Note

Due to limitations with Sphinx/autoenum, only a subset of all values are documented here.

Member Type:

int

Valid values are as follows:

ARTILLERY_TURRET_AMMO = <InventoryType.ARTILLERY_TURRET_AMMO: 1>
ASSEMBLING_MACHINE_INPUT = <InventoryType.ASSEMBLING_MACHINE_INPUT: 2>
ASSEMBLING_MACHINE_OUTPUT = <InventoryType.ASSEMBLING_MACHINE_OUTPUT: 3>
ASSEMBLING_MACHINE_MODULES = <InventoryType.ASSEMBLING_MACHINE_MODULES: 4>
CHARACTER_ARMOR = <InventoryType.CHARACTER_ARMOR: 5>
BURNT_RESULT = <InventoryType.BURNT_RESULT: 6>
ASSEMBLING_MACHINE_DUMP = <InventoryType.ASSEMBLING_MACHINE_DUMP: 7>
CHARACTER_TRASH = <InventoryType.CHARACTER_TRASH: 8>
ROCKET_SILO_ROCKET = <InventoryType.ROCKET_SILO_ROCKET: 9>
ROCKET_SILO_TRASH = <InventoryType.ROCKET_SILO_TRASH: 11>
enum LampColorMode(value)

In what manner should circuit signals sent to a Lamp be interpreted when determining that Lamp’s color.

Member Type:

int

Valid values are as follows:

COLOR_MAPPING = <LampColorMode.COLOR_MAPPING: 0>

The given signal type broadcasts that particular color, so providing the signal "signal-red" will display the color red. If multiple color signals are provided, the first one according to sort order is displayed.

COMPONENTS = <LampColorMode.COMPONENTS: 1>

Three signals are used, where the value of each one corresponds to the 8-bit red, green, and blue values of the final color.

PACKED_RGB = <LampColorMode.PACKED_RGB: 2>

One signal is used, where each color component is pulled from a specific 8-bits of the input signal.

enum LegacyDirection(value)

Old Factorio direction enum. Encompasses all 8 cardinal directions and diagonals in the range [0, 7] where north is 0 and incrementing clockwise. Provides a number of convenience constants and functions over working with a raw int value.

Member Type:

int

Valid values are as follows:

NORTH = <LegacyDirection.NORTH: 0>
NORTHEAST = <LegacyDirection.NORTHEAST: 1>
EAST = <LegacyDirection.EAST: 2>
SOUTHEAST = <LegacyDirection.SOUTHEAST: 3>
SOUTH = <LegacyDirection.SOUTH: 4>
SOUTHWEST = <LegacyDirection.SOUTHWEST: 5>
WEST = <LegacyDirection.WEST: 6>
NORTHWEST = <LegacyDirection.NORTHWEST: 7>

The Enum and its members also have the following methods:

opposite() LegacyDirection

Returns the direction opposite this one.

>>> LegacyDirection.NORTH.opposite()
<LegacyDirection.SOUTH: 4>
Returns:

A new Direction.

next(eight_way: bool = False) LegacyDirection

Returns the direction one unit clockwise from the current direction. eight_way determines whether or not to treat the next-most direction from a four-way or eight-way perspective; for example:

>>> LegacyDirection.NORTH.next(eight_way=False)
<LegacyDirection.EAST: 2>
>>> LegacyDirection.NORTH.next(eight_way=True)
<LegacyDirection.NORTHEAST: 1>
Parameters:
eight_way: bool = False

Whether to increment the current direction by 1 or 2 units.

Returns:

The following direction.

previous(
eight_way: bool = False,
) LegacyDirection

Returns the direction one unit counter-clockwise from the current direction. eight_way determines whether or not to treat the previous-most direction from a four-way or eight-way perspective; for example:

>>> LegacyDirection.NORTH.previous(eight_way=False)
<LegacyDirection.WEST: 6>
>>> LegacyDirection.NORTH.previous(eight_way=True)
<LegacyDirection.NORTHWEST: 7>
Parameters:
eight_way: bool = False

Whether to increment the current direction by 1 or 2 units.

Returns:

The preceding direction.

to_orientation() Orientation

Converts this direction to an Orientation of corresponding value.

>>> LegacyDirection.EAST.to_orientation()
<Orientation.EAST: 0.25>
Returns:

An equivalent Orientation object.

to_vector(magnitude: float = 1.0) Vector

Converts a Direction into an equivalent 2-dimensional vector, for various linear operations. Works with both four-way and eight-way directions. Returned vectors are unit-length, unless magnitude is specified.

>>> LegacyDirection.NORTH.to_vector(magnitude=2)
Vector(0, -2)
>>> LegacyDirection.SOUTHWEST.to_vector()
Vector(-0.7071067811865476, 0.7071067811865476)
Parameters:
magnitude: float = 1.0

The magnitude (total length) of the vector to create.

Returns:

A new Vector object pointing in the correct direction.

to_modern() Direction

Converts this LegacyDirection to a Direction.

enum LogisticModeOfOperation(value)

Logistics container circuit control constants. Determines how the Entity should behave when connected to a circuit network.

Member Type:

int

Valid values are as follows:

SEND_CONTENTS = <LogisticModeOfOperation.SEND_CONTENTS: 0>

Reads the inventory of the container and sends it to the connected circuit network.

SET_REQUESTS = <LogisticModeOfOperation.SET_REQUESTS: 1>

Sets the item requests based on the input signals to the container.

NONE = <LogisticModeOfOperation.NONE: 2>

Does nothing with the connected circuit network.

enum MiningDrillReadMode(value)

Used to specify whether the mining drill will read just the resources accessible to it or the entire resource patch.

Member Type:

int

Valid values are as follows:

UNDER_DRILL = <MiningDrillReadMode.UNDER_DRILL: 0>

Only return the resources directly minable by this drill.

TOTAL_PATCH = <MiningDrillReadMode.TOTAL_PATCH: 1>

Return the entire contents of the ore patches the drill is over.

class Orientation(value: float)

Factorio orientation enum. Represents the direction an object is facing with a floating point number in the range [0.0, 1.0) where north is 0.0 and increases clockwise. Provides a number of convenience constants and functions over working with a raw float value.

Note

Currently only supports addition and subtraction. If you want to perform more complex operations, it’s best to convert it to a float and then convert it back to an Orientation when complete.

opposite() Orientation

Returns the direction opposite this one. For cardinal four-way and eight- way directions calling this function should always return the “true” opposite; but when calling on an arbitrary orientation the opposite may succumb to floating point error:

>>> Orientation.NORTH.opposite()
<Orientation.SOUTH: 0.5>
>>> Orientation.NORTHWEST.opposite()
<Orientation.SOUTHEAST: 0.375>
>>> Orientation(0.9).opposite()
<Orientation: 0.3999999999999999>
Returns:

A new Orientation object.

to_direction(sixteen_way: bool = False) Direction

Converts the orientation to a Direction instance. If the orientation is imprecise, the orientation will be rounded to either the closest four-way or eight-way direction.

>>> example = Orientation(1.0 / 3.0)
>>> example.to_direction(sixteen_way=False)
<Direction.EAST: 4>
>>> example.to_direction(sixteen_way=True)
<Direction.EASTSOUTHEAST: 5>
Parameters:
sixteen_way: bool = False

Whether to round to the closest four-way direction or sixteen-way direction.

Returns:

A new Direction object.

to_vector(magnitude=1) Vector

Converts a Orientation into an equivalent 2-dimensional vector, for various linear operations. Returned vectors are unit-length, unless magnitude is altered.

>>> Orientation.NORTH.to_vector(magnitude=2)
Vector(0.0, -2.0)
>>> Orientation.SOUTHWEST.to_vector()
Vector(-0.7071067811865475, 0.7071067811865477)
Parameters:
magnitude=1

The magnitude (total length) of the vector to create.

Returns:

A new Vector object pointing in the corresponding direction.

enum SiloReadMode(value)

Determines how rocket silos should interact with the circuit network.

Member Type:

int

Valid values are as follows:

NONE = <SiloReadMode.NONE: 0>

Do nothing.

READ_CONTENTS = <SiloReadMode.READ_CONTENTS: 1>

Send the contents of the currently loaded rocket.

READ_ORBITAL_REQUESTS = <SiloReadMode.READ_ORBITAL_REQUESTS: 2>

Send the set of items desired by all space platforms in orbit.

Added in version 3.0.0: (Factorio 2.0)

enum Ticks(value)

Constant values that correspond to the number of Factorio ticks for that measure of time at normal game-speed.

Member Type:

int

Valid values are as follows:

SECOND = <Ticks.SECOND: 60>
MINUTE = <Ticks.MINUTE: 3600>
HOUR = <Ticks.HOUR: 216000>
DAY = <Ticks.DAY: 5184000>

The Enum and its members also have the following methods:

classmethod from_timedelta(td: timedelta) int

Converts a timedelta into the closest number of Factorio ticks that measures that duration.

Example:

>>> from datetime import datetime
>>> t1 = datetime.strptime("10:15:04", "%H:%M:%S")
>>> t2 = datetime.strptime("10:19:27", "%H:%M:%S")
>>> td = t2 - t1
>>> Ticks.from_timedelta(td)
15780
Parameters:
td: timedelta

The difference in time between two points.

Returns:

The equivalent number of ticks representing this difference, rounded to the nearest tick.

enum TileSelectionMode(value)

Tile selection mode for UpgradePlanner.

Member Type:

int

Valid values are as follows:

NORMAL = <TileSelectionMode.NORMAL: 0>

Tiles are only selected if there are no entities in the selected area.

ALWAYS = <TileSelectionMode.ALWAYS: 1>

Tiles are always selected regardless of selection contents.

NEVER = <TileSelectionMode.NEVER: 2>

Tiles are never selected regardless of selection contents.

ONLY = <TileSelectionMode.ONLY: 3>

Only tiles are selected and entities are completely ignored.

enum ValidationMode(value)

The manner in which to validate a given Draftsman object.

Valid values are as follows:

DISABLED = <ValidationMode.DISABLED: 'disabled'>

No validation will be performed at all. Shorthand conversions will still take place, meaning that all values will still attempt to be coerced to their internal form whenever possible.

MINIMUM = <ValidationMode.MINIMUM: 'minimum'>

The minimum amount of validation needed in order to validate that the structure of the object conforms to what Factorio expects. Importing an object that has been validated with this mode is not guaranteed to succeed, as while the object might be structurally correct, the data inside of it might still be malformed.

STRICT = <ValidationMode.STRICT: 'strict'>

The default mode. Includes all of the errors from MINIMUM, but attempts to point out and remedy issues with the objects values. Also includes conceptual faults that will not result in the intended effect, such as setting an assembling machine’s recipe to something that it cannot produce.

PEDANTIC = <ValidationMode.PEDANTIC: 'pedantic'>

The most verbose option. Includes all of the previous errors and warnings, in addition to more linting-like behavior.

enum WaitConditionCompareType(value)

All valid string identitfiers for the type of comparison between multiple WaitCondition objects.

Member Type:

str

Valid values are as follows:

AND = <WaitConditionCompareType.AND: 'and'>

Boolean AND this condition with the subsequent one.

OR = <WaitConditionCompareType.OR: 'or'>

Boolean OR this conditions with the subsequent one.

enum WaitConditionType(value)

All valid string identifiers for the type of a train’s or space platform’s WaitCondition object.

Member Type:

str

Valid values are as follows:

ALL_REQUESTS_STATISFIED = <WaitConditionType.ALL_REQUESTS_STATISFIED: 'all_requests_satisfied'>

Trigger if all of the logistics requests at this particular planet are satisfied.

ANY_PLANET_IMPORT_ZERO = <WaitConditionType.ANY_PLANET_IMPORT_ZERO: 'any_planet_import_zero'>

Trigger if any of the logistics requests for any planet are zero.

ANY_REQUEST_NOT_SATISFIED = <WaitConditionType.ANY_REQUEST_NOT_SATISFIED: 'any_request_not_satisfied'>

Trigger if any logistics request on the space platform is below satisfaction.

ANY_REQUEST_ZERO = <WaitConditionType.ANY_REQUEST_ZERO: 'any_request_zero'>

Trigger if any logistics request on the space platform is zero.

AT_STATION = <WaitConditionType.AT_STATION: 'at_station'>

Trigger if the vehicle is currently stopped at a particular location on it’s route.

CIRCUIT_CONDITION = <WaitConditionType.CIRCUIT_CONDITION: 'circuit'>

Trigger if a circuit condition for that stop evaluates to true.

DAMAGE_TAKEN = <WaitConditionType.DAMAGE_TAKEN: 'damage_taken'>

Trigger if the space platform has taken damage beyond a specific threshold.

DESTINATION_FULL_OR_NO_PATH = <WaitConditionType.DESTINATION_FULL_OR_NO_PATH: 'destination_full_or_no_path'>

Trigger if the locomotive has no feasible way to get to it’s next stop on it’s schedule, either by a lack of space at the destination stop or because there is no physical route to the station.

EMPTY_CARGO = <WaitConditionType.EMPTY_CARGO: 'empty'>

Trigger if the cargo for this entity is entirely empty.

FLUID_COUNT = <WaitConditionType.FLUID_COUNT: 'fluid_count'>

Trigger if the fluid cargo in the locomotive is beyond a particular threshold.

FUEL_COUNT_ALL = <WaitConditionType.FUEL_COUNT_ALL: 'fuel_item_count_all'>

Triggered if the fuel in all locomotives is beyond some threshold.

FUEL_COUNT_ANY = <WaitConditionType.FUEL_COUNT_ANY: 'fuel_item_count_any'>

Triggered if the fuel in any locomotive is beyond some threshold.

FULL_CARGO = <WaitConditionType.FULL_CARGO: 'full'>

Triggered if the item cargo space is entirely occupied in this vehicle.

FULL_FUEL = <WaitConditionType.FULL_FUEL: 'fuel_full'>

Triggered when all locomotives are entirely full of fuel.

NOT_EMPTY = <WaitConditionType.NOT_EMPTY: 'not_empty'>

Triggered when the vehicle is not entirely empty of cargo.

INACTIVITY = <WaitConditionType.INACTIVITY: 'inactivity'>

Triggered after the vehicle has been inactive for a specified period of time.

ITEM_COUNT = <WaitConditionType.ITEM_COUNT: 'item_count'>

Triggered when a certain number of a particular item is contained within this vehicles inventory.

NOT_AT_STATION = <WaitConditionType.NOT_AT_STATION: 'not_at_station'>

Triggered when a train is not located at a particular station.

PASSENGER_PRESENT = <WaitConditionType.PASSENGER_PRESENT: 'passenger_present'>

Triggered when a passenger is present in the vehicle (train or space platform).

PASSENGER_NOT_PRESENT = <WaitConditionType.PASSENGER_NOT_PRESENT: 'passenger_not_present'>

Triggered when a passenger is not present in the vehicle (train or space platform).

REQUEST_SATISFIED = <WaitConditionType.REQUEST_SATISFIED: 'request_satisfied'>

Triggered when a space platform logistic request is satisfied.

REQUEST_NOT_SATISFIED = <WaitConditionType.REQUEST_NOT_SATISFIED: 'request_not_satisfied'>

Triggered when a space platform logistic request is not satisfied.

SPECIFIC_DESTINATION_FULL = <WaitConditionType.SPECIFIC_DESTINATION_FULL: 'specific_destination_full'>

Triggered when a specific station name is full.

SPECIFIC_DESTINATION_NOT_FULL = <WaitConditionType.SPECIFIC_DESTINATION_NOT_FULL: 'specific_destination_not_full'>

Triggered when a specific station name is not full.

TIME_PASSED = <WaitConditionType.TIME_PASSED: 'time'>

Triggered when a certain number of ticks has passed.

enum WireColor(value)

The valid wire colors for circuit connection types in Factorio, either red or green.

Member Type:

str

Valid values are as follows:

RED = <WireColor.RED: 'red'>
GREEN = <WireColor.GREEN: 'green'>
enum WireConnectorID(value)

Constants which define which type of connection point this particular wire connects to.

Member Type:

int

Valid values are as follows:

COMBINATOR_INPUT_RED = <WireConnectorID.COMBINATOR_INPUT_RED: 1>
COMBINATOR_INPUT_GREEN = <WireConnectorID.COMBINATOR_INPUT_GREEN: 2>
COMBINATOR_OUTPUT_RED = <WireConnectorID.COMBINATOR_OUTPUT_RED: 3>
COMBINATOR_OUTPUT_GREEN = <WireConnectorID.COMBINATOR_OUTPUT_GREEN: 4>
POLE_COPPER = <WireConnectorID.POLE_COPPER: 5>
POWER_SWITCH_RIGHT_COPPER = <WireConnectorID.POWER_SWITCH_RIGHT_COPPER: 6>