filters

class FiltersMixin(name: str, similar_entities: list[str], **kwargs: dict)

Allows the entity to specify item filters.

set_item_filter(index: int, item: str) None

Sets one of the item filters of the Entity. index in this function is in 0-based notation.

Parameters:
  • index – The index of the filter to set.

  • item – The string name of the item to filter.

Raises:
  • IndexError – If index is set to a value exceeding or equal to filter_count.

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

set_item_filters(filters: list) None

Sets all of the item filters of the Entity.

filters can be either of the following 2 formats:

[{"index": int, "name": item_name_1}, ...]
# Or
[item_name_1, item_name_2, ...]

With the first format, the “index” key is in 1-based notation. With the second format, the index of each item is set to it’s position in the list. filters can also be None, which will wipe all item filters that the Entity has.

Parameters:

filters – The item filters to give the Entity.

Raises:
  • DataFormatError – If the filters argument does not match the specification above.

  • IndexError – If the index of one of the entries exceeds or equals the filter_count of the Entity.

  • InvalidItemError – If the item name of one of the entries is not valid.

property filter_count: int

The number of filter slots that this Entity has in total. Equivalent to the "filter_count" key in Factorio’s data.raw. Not exported; read only.

Type:

int