logistic_buffer_container
- class LogisticBufferContainer(name: str = 'logistic-chest-buffer', **kwargs: dict)
Bases:
InventoryMixin
,RequestItemsMixin
,LogisticModeOfOperationMixin
,ControlBehaviorMixin
,CircuitConnectableMixin
,RequestFiltersMixin
,Entity
A logistics container that requests items on a secondary priority.
- classmethod dump_format() dict
Dumps a JSON-serializable representation of the Entity’s
exports
dictionary, primarily for user interpretation.- Returns:
A JSON dictionary containing the names of each valid key, a short description of their purpose, and whether or not they’re considered optional.
- classmethod get_format() str
Produces a pretty string representation of
meth:dump_format
. Work in progress.- Returns:
A formatted string that can be output to stdout or file.
- get_world_bounding_box()
Gets the world-space coordinates AABB that completely encompasses the
collision_set
of this SpatialLike. Behaves similarly to the old function get_area(), except now it correctly handles non-AABB collision shapes.
- get_world_collision_set() CollisionSet
Get’s the world-space coordinate CollisionSet of the object, or the collection of all shapes that this EntityLike interacts with.
- Returns:
A new
CollisionSet
with it’s content’s copied.
- mergable_with(other: Entity) bool
Checks to see if an entity is “mergable” with another entity. This means that if a certain set of criteria is met, the attributes of
other
will be combined to the attributes of this entity. This is useful for mimicking cases where entities of the same name and type are placed on top of each other, merging them together into a single entity with shared attributes.For the full list of all merging rules, see (TODO).
Note
This function does not actually merge the two, it simply checks to see if such a merge is considered valid. To actually merge two entities use
merge()
.- Parameters:
other – The other
EntityLike
to check against.- Returns:
True
if they can be merged,False
otherwise.
- merge(other: Entity) None
Changes the attributes of the calling entity with the attributes of the passed in entity. The attributes of
other
take precedence over the attributes of the calling entity. They can be either copied or merged together, depending on the specific attribute being merged.For the full list of all merging rules, see (TODO).
- Parameters:
other – The other
EntityLike
to merge with.
- on_insert(parent: EntityCollection) None
TODO
- on_remove(parent: EntityCollection) None
TODO
- set_item_request(item: str, count: int) None
Issues warnings if the set item exceeds the inventory size of the entity.
- set_item_requests(items: dict) None
Sets all of the item requests for the Entity. Takes
items
as adict
in the format:{item_1: count_1, item_2: count_2, ...}
where
item_x
is astr
andcount_x
is a positive integer.- Parameters:
items – A dictionary of the desired items in the format specified above.
- Raises:
TypeError – If
item_x
is anything other than astr
, or ifcount_x
is anything other than anint
orNone
.InvalidItemError – If
item_x
is not a valid item name.ValueError – If
count_x
is less than zero.
- set_request_filter(index: int, item: str, count: int | None = None) None
Sets the request filter at a particular index to request an amount of a certain item. Factorio imposes that an Entity can only have 1000 active requests at the same time.
- Parameters:
index – The index of the item request.
item – The item name to request, or
None
.count – The amount to request. If set to
None
, it defaults to the stack size ofitem
.
- Raises:
TypeError – If
index
is not anint
,item
is not astr
orNone
, orcount
is not anint
.InvalidItemError – If
item
is not a valid item name.IndexError – If
index
is not in the range[0, 1000)
.
- set_request_filters(filters: list) None
Sets all the request filters of the Entity, where filters is of the format:
[(item_1, count_1), (item_2, count_2), ...]
where
item_x
is astr
name andcount_x
is a positive integer.- Parameters:
filters – The request filters to set.
- Raises:
DataFormatError – If
filters
does not match the format specified above.InvalidItemError – If
item_x
is not a valid item name.
- to_dict() dict
Converts the Entity to its JSON dict representation. The keys returned are determined by the contents of the exports dictionary and their criteria functions.
A attribute from the Entity will be included as a key in the output dict if both of the following conditions are met:
The attribute is in the
exports
dictionaryThe associated criteria function is either not present or returns
True
. This is used to avoid including excess keys, keeping Blueprint string size down.
In addition, a second function may be provided to have a formatting step to alter either the key and/or its value, which gets inserted into the output
dict
.- Returns:
The exported JSON-dict representation of the Entity.
- property bar: int
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’sinventory_size
attribute.- Getter:
Gets the bar location of the inventory.
- Setter:
Sets the bar location of the inventory.
- Type:
int
- Raises:
DraftsmanError – If attempting to set the bar of an Entity that has the
inventory_bar_enabled
attribute set toFalse
.TypeError – If set to anything other than an
int
orNone
.IndexError – If the set value lies outside of the range
[0, 65536)
.
- property circuit_connectable: bool
Whether or not this EntityLike can be connected using circuit wires. Not exported; read only.
- Type:
bool
- property circuit_wire_max_distance: int
The maximum distance that this entity can reach for circuit connections. Not exported; read only.
- Type:
float
- property collision_mask: set
The set of all collision layers that this Entity collides with, specified as strings. Equivalent to Factorio’s
data.raw
equivalent. Not exported; read only.- Type:
set{str}
- property collision_set: CollisionSet
TODO
- property connections: dict
Connections dictionary. Primarily holds information about the Entity’s circuit connections (as well as copper wire connections).
- Type:
- Raises:
DataFormatError – If set to anything that does not match the format of
draftsman.signatures.CONNECTIONS
.
- property control_behavior: dict
The
control_behavior
of the Entity.- Getter:
Gets the
control_behavior
.- Setter:
Sets the
control_behavior
. Gets set to an emptydict
if set toNone
.- Type:
- Raises:
DataFormatError – If set to anything that does not match the
CONTROL_BEHAVIOR
signature.
- property double_grid_aligned: bool
Whether or not this EntityLike is “double-grid-aligned”, which applies to a number of rail entities. Not exported; read only.
- Type:
bool
- property dual_circuit_connectable: bool
Whether or not this EntityLike has two circuit connection points. Not exported; read only.
- Type:
bool
- property dual_power_connectable: bool
Whether or not this EntityLike has two power connection points. Not exported; read only.
- Type:
bool
- property flippable: bool
Whether or not this entity can be mirrored in game using ‘F’ or ‘G’. Not exported; read only.
Note
Work in progress. May be incorrect, especially for modded entities.
- property global_position: dict
The “global”, or root-most position of the Entity. This value is always equivalent to
position()
, unless the entity exists inside anEntityCollection
. If it does, then it’s global position is equivalent to the sum of all parent positions plus it’s own position. For example, if an Entity exists within aGroup
at position(5, 5)
and theGroup
exists at(5, 5)
, theglobal_position
of the Entity will be(10, 10)
.This is used to get an entity’s “actual” position in a blueprint, used when adding to a
SpatialHashMap
and when querying the entity by region. This attribute is always exported, but renamed to “position”; read only.- Type:
dict{"x": float, "y": float}
Whether or not this Entity is considered “hidden”, as specified in it’s flags in Factorio’s
data.raw
. Not exported; read only.Note
“Hidden” in this context is somewhat unintuitive, as items you might think would be considered hidden may not be. Ship wreckage entities, for example, are not considered “hidden”, even though the only way to access them is with the editor. Keep this in mind when querying this attribute, especially since this discrepancy might be considered a bug later on.
- Type:
bool
- property id: str
A unique string ID associated with this entity. ID’s can be anything, though there can only be one entity with a particular ID in an EntityCollection. Not exported.
- Getter:
Gets the ID of the entity, or
None
if the entity has no ID.- Setter:
Sets the ID of the entity.
- Type:
str
- Raises:
TypeError – If the set value is anything other than a
str
orNone
.DuplicateIDError – If the ID is changed while inside an
EntityCollection
to an ID that is already taken by another entity in saidEntityCollection
.
- property inventory_bar_enabled: bool
Whether or not this Entity has its inventory limiting bar enabled. Equivalent to the
"enable_inventory_bar"
key in Factorio’sdata.raw
. Not exported; read only.- Type:
bool
- property inventory_size: int
The number of inventory slots that this Entity has. Equivalent to the
"inventory_size"
key in Factorio’sdata.raw
. Not exported; read only.- Type:
int
- property inventory_slots_occupied: int
The number of inventory slots filled by the item requests for this entity. Used to keep track of requested items and issue warnings if the amount inside the container exceeds the inventory size of the entity. Not exported; read only.
- property mode_of_operation: LogisticModeOfOperation
The behavior that the logistic container should follow when connected to a circuit network.
- Getter:
Gets the mode of operation, or
None
if not set.- Setter:
Sets the mode of operation. Removes the key if set to
None
.- Type:
- Raises:
ValueError – If set to a value that cannot be interpreted as a valid
LogisticModeOfOperation
.
- property name: str
The name of the entity. Must be a valid Factorio ID string. Read only.
- Type:
str
- property parent: EntityCollection
The parent
EntityCollection
object that contains the entity, orNone
if the entity does not currently exist within anEntityCollection
. Not exported; read only.- Type:
EntityCollection
- property position: Vector
The “canonical” position of the Entity, or the one that Factorio uses. Positions of most entities are located at their center, which can either be in the middle of a tile or on it’s transition, depending on the Entity’s
tile_width
andtile_height
.position
can be specified as adict
with"x"
and"y"
keys, or more succinctly as a sequence of floats, usually alist
ortuple
.position
can also be specified more verbosely as aVector
instance as well.This property is updated in tandem with
tile_position
, so using them both interchangeably is both allowed and encouraged.- Getter:
Gets the position of the Entity.
- Setter:
Sets the position of the Entity.
- Type:
- Raises:
IndexError – If the set value does not match the above specification.
DraftsmanError – If the entities position is modified when inside a EntityCollection, which is forbidden.
- property power_connectable: bool
Whether or not this EntityLike can be connected using power wires. Not exported; read only.
- Type:
bool
- property rotatable: bool
Whether or not this EntityLike can be rotated. Note that this does not mean that the entity will prevent a blueprint from rotating; more, that this EntityLike does not have a concept of different rotation angles. For example, any
Reactor
entity will always returnrotatable
asFalse
when queried. Not exported; read only.- Type:
bool
- property tags: dict
Tags associated with this Entity. Commonly used by mods to add custom data to a particular Entity when exporting and importing Blueprint strings.
- Getter:
Gets the tags of the Entity, or
None
if not set.- Setter:
Sets the Entity’s tags.
- Type:
dict{Any: Any}
- Raises:
TypeError – If tags is set to anything other than a
dict
orNone
.
- property tile_height: int
The height of the entity in tiles, rounded up to the nearest integer. Not exported; read only.
- Type:
int
- property tile_position: Vector
The tile-position of the Entity. The tile position is the position according the the LuaSurface tile grid, and is the top left corner of the top-leftmost tile of the Entity.
tile_position
can be specified as adict
with"x"
and"y"
keys, or more succinctly as a sequence of floats, usually alist
ortuple
.This property is updated in tandem with
position
, so using them both interchangeably is both allowed and encouraged.- Getter:
Gets the tile position of the Entity.
- Setter:
Sets the tile position of the Entity.
- Type:
- Raises:
IndexError – If the set value does not match the above specification.
DraftsmanError – If the entities position is modified when inside a EntityCollection, which is forbidden.
- property tile_width: int
The width of the entity in tiles, rounded up to the nearest integer. Not exported; read only.
- Type:
int
- property type: str
The type of the Entity. Equivalent to the key found in Factorio’s
data.raw
. Mostly equivalent to the type of the entity instance, though there are some differences, as noted here. Can be used as a criteria to search with inEntityCollection.find_entities_filtered()
. Not exported; read only.- Type:
str