deconstruction_planner

{
    "deconstruction_planner": {
        "item": "deconstruction-planner", # The associated item with this structure
        "label": str, # A user given name for this deconstruction planner
        "version": int, # The encoded version of Factorio this planner was created 
                        # with/designed for (64 bits)
        "settings": {
            "entity_filter_mode": int, # 0 = Whitelist, 1 = Blacklist
            "entity_filters": [ # A list of entities to deconstruct
                {
                    "name": str, # Name of the entity
                    "index": int # Index of the entity in the list in range [1, 30]
                },
                ... # Up to 30 filters total
            ]
            "trees_and_rocks_only": bool, # Self explanatory, disables everything 
                                          # else
            "tile_filter_mode": int, # 0 = Whitelist, 1 = Blacklist
            "tile_filters": [ # A list of tiles to deconstruct
                {
                    "name": str, # Name of the tile
                    "index": int # Index of the tile in the list in range [1, 30]
                },
                ... # Up to 30 filters total
            ]
            "tile_selection_mode": int, # 0 = Normal, 1 = Always, 2 = Never, 
                                        # 3 = Only
            "description": str, # A user given description for this deconstruction 
                                # planner
            "icons": [ # A set of signals to act as visual identification
                {
                    "signal": {"name": str, "type": str}, # Name and type of signal
                    "index": int, # In range [1, 4], starting top-left and moving across
                },
                ... # Up to 4 icons total
            ],
        }
    }
}
class DeconstructionPlanner(deconstruction_planner: str | dict = None)

Bases: Blueprintable

Handles the deconstruction of entities. Has functionality to only select certain entities or tiles, as well as only natrual objects like trees and rocks.

load_from_string(string: str) None

Load the Blueprintable with the contents of string.

Raises DraftsmanWarning if there are any unrecognized keywords in the blueprint string for this particular blueprintable.

Parameters:

string – Factorio-encoded blueprint string.

Raises:
set_entity_filter(index: int, name: str) None

TODO

set_tile_filter(index: int, name: str) None

TODO

setup(**kwargs)

Setup the Blueprintable’s parameters with the input keywords as values. Primarily used by the constructor, but can be used at any time to set a large number of keys all at once.

Raises DraftsmanWarning if any of the input keywords are unrecognized.

Parameters:

kwargs – The dict of all keywords to set in the blueprint.

Note

Calling setup only sets the specified keys to their values, and everything else to either their defaults or None. In other words, the effect of calling setup multiple times is not cumulative, but rather set to the keys in the last call.

Example:

>>> from draftsman.blueprintable import Blueprint
>>> blueprint = Blueprint()
>>> blueprint.setup(label="test")
>>> assert blueprint.label == "test"
>>> test_dict = {"description": "testing..."}
>>> blueprint.setup(**test_dict)
>>> assert blueprint.description == "testing..."
>>> assert blueprint.label == None # Gone!
to_dict()

Returns the blueprintable as a dictionary. Intended for getting the precursor to a Factorio blueprint string before encoding and compression takes place.

Returns:

The dict representation of the Blueprintable.

to_string() str

Returns this object as an encoded Factorio blueprint string.

Returns:

The zlib-compressed, base-64 encoded string.

Example:

>>> from draftsman.blueprintable import (
...     Blueprint, DeconstructionPlanner, UpgradePlanner, BlueprintBook
... )
>>> Blueprint({"version": (1, 0)}).to_string()
'0eNqrVkrKKU0tKMrMK1GyqlbKLEnNVbJCEtNRKkstKs7Mz1OyMrIwNDE3sTQ3Mzc0MDM1q60FAHmVE1M='
>>> DeconstructionPlanner({"version": (1, 0)}).to_string()
'0eNpdy0EKgCAQAMC/7Nkgw7T8TIQtIdga7tol/HtdunQdmBs2DJlYSg0SMy1nWomwgL+BUSTSzuCppqQgCh7gf6H7goILC78Cfpi0cWZ21unejra1B7C2I9M='
>>> UpgradePlanner({"version": (1, 0)}).to_string()
'0eNo1yksKgCAUBdC93LFBhmm5mRB6iGAv8dNE3Hsjz/h0tOSzu+lK0TFThu0oVGtgX2C5xSgQKj2wcy5zCnyUS3gZdjukMuo02shV73qMH4ZxHbs='
>>> BlueprintBook({"version": (1, 0)}).to_string()
'0eNqrVkrKKU0tKMrMK4lPys/PVrKqVsosSc1VskJI6IIldJQSk0syy1LjM/NSUiuUrAx0lMpSi4oz8/OUrIwsDE3MTSzNzcwNDcxMzWprAVWGHQI='
version_string() str

Returns the version of the Blueprintable in human-readable string.

Returns:

a str of 4 version numbers joined by a ‘.’ character.

Example:

>>> from draftsman.blueprintable import Blueprint
>>> blueprint = Blueprint({"version": (1, 2, 3)})
>>> blueprint.version_string()
'1.2.3.0'
version_tuple()

Returns the version of the Blueprintable as a 4-length tuple.

Returns:

A 4 length tuple in the format (major, minor, patch, dev_ver).

Example:

>>> from draftsman.blueprintable import Blueprint
>>> blueprint = Blueprint({"version": 281474976710656})
>>> blueprint.version_tuple()
(1, 0, 0, 0)
property description: str

The description of the blueprintable. Visible when hovering over it when inside someone’s inventory.

Getter:

Gets the description, or None if not set.

Setter:

Sets the description of the object. Removes the attribute if set to None.

Type:

str

Raises:

TypeError – If setting to anything other than a str or None.

property entity_filter_mode: FilterMode

TODO

property entity_filters: list[dict]

TODO

property icons: list

The visible icons of the blueprintable, shown in as the objects icon.

Stored as a list of ICON objects, which are dicts that contain a SIGNAL_ID and an index key. Icons can be specified in this format, or they can be specified more succinctly with a simple list of signal names as strings.

All signal entries must be a valid signal ID. If the input format is a list of strings, the index of each item will be it’s place in the list + 1. A max of 4 icons are permitted.

Getter:

Gets the list if icons, or None if not set.

Setter:

Sets the icons of the Blueprint. Removes the attribute if set to None.

Type:

{"index": int, "signal": {"name": str, "type": str}}

Raises:

DataFormatError – If the set value does not match either of the specifications above.

Example:

>>> from draftsman.blueprintable import Blueprint
>>> blueprint = Blueprint()
>>> blueprint.icons = ["transport-belt"]
>>> blueprint.icons
[{'index': 1, 'signal': {'name': 'transport-belt', 'type': 'item'}}]
property item: str

Always the name of the corresponding Factorio item to this blueprintable instance. Read only.

Type:

str

Example:

>>> from draftsman.blueprintable import (
...     Blueprint, DeconstructionPlanner, UpgradePlanner, BlueprintBook
... )
>>> Blueprint().item
'blueprint'
>>> DeconstructionPlanner().item
'deconstruction-planner'
>>> UpgradePlanner().item
'upgrade-planner'
>>> BlueprintBook().item
'blueprint-book'
property label: str

The user given name (title) of the blueprintable.

Getter:

Gets the label, or None if not set.

Setter:

Sets the label of this object.

Type:

str

Raises:

TypeError – When setting label to something other than str or None.

property tile_filter_mode: FilterMode

TODO

property tile_filters: list[dict]

TODO

property tile_selection_mode: TileSelectionMode

TODO

property trees_and_rocks_only: bool

TODO

property version: int

The version of Factorio the Blueprint was created in/intended for.

The Blueprint version is a 64-bit integer, which is a bitwise-OR of four 16-bit numbers. You can interpret this number more clearly by decoding it with draftsman.utils.decode_version(), or you can use the functions version_tuple() or version_string() which will give you a more readable output. This version number defaults to the version of Factorio that Draftsman is currently initialized with.

The version can be set either as said 64-bit int, or a sequence of ints, usually a list or tuple, which is then encoded into the combined representation. The sequence is defined as: [major_version, minor_version, patch, development_release] with patch and development_release defaulting to 0.

Getter:

Gets the version, or None if not set.

Setter:

Sets the version of the Blueprint. Removes the attribute if set to None.

Type:

int

Raises:

TypeError – If set to anything other than an int, sequence of ints, or None.

Example:

>>> from draftsman.blueprintable import Blueprint
>>> blueprint = Blueprint()
>>> blueprint.version = (1, 0) # version 1.0.0.0
>>> assert blueprint.version == 281474976710656
>>> assert blueprint.version_tuple() == (1, 0, 0, 0)
>>> assert blueprint.version_string() == "1.0.0.0"