Skip to main content

A small package to manipulate factorio blueprints

Project description

factoriolib

This repository contains a python package able to create and mainpulate factorio blueprint

Usage

Basics

In order to create simple blueprints you can simply create the entity objects needed and push them into the blueprint's entities list:

from factoriolib import entities
from factoriolib import blueprints
from factoriolib.core import Position, Direction

# Create a set of entity instances
transportBelt = entities.TransportBelt(
    position=Position(0.5, -0.5),
    direction=Direction(Direction.EAST)
)

inserter = entities.Inserter(
    position=Position(0.5, 0.5),
    direction=Direction(Direction.SOUTH)
)

chest = entities.WoodenChest(
    position=Position(0.5, 1.5)
)

pump = entities.Pump(
    position=Position(1.5, 0.5),
    direction=Direction(Direction.NORTH)
)

# create a blueprint instance
blueprint = blueprints.Blueprint()

# access the blueprint's entities and push all newly created entities into it
blueprint.entities().push(transportBelt, inserter, chest, pump)

# print the dict representation of the blueprint
print(blueprint.toDict())

# print the factorio exchange string
print(blueprint.exchangeString())

The generated exchange string can be imported into your game.

Filters

Some entities such as chests may have logistics filters or a bar (the limit as to how many slots may be filled).

from factoriolib import entities
from factoriolib import blueprints
from factoriolib.core import Position, LogisticFilter
from factoriolib.items import Wood, IronPlate

# Create a requester chest for wood and iron plates with a limit to 3 slots
chest = entities.LogisticChestRequester(
    position=Position(0.5, 0.5),
    bar=3
)

# add the filters (note that the index is 1 based)
chest.request_filters().push(
    LogisticFilter(Wood.name(), 1, 1337),
    LogisticFilter(IronPlate.name(), 2, 42),
)

Circuit network

Entities that may be connected to a circuit network may be connected using the ConnectionMaker helper:

from factoriolib import entities
from factoriolib import blueprints
from factoriolib.core import Position, CircuitCondition, Signal
from factoriolib.utility import ConnectionMaker
from factoriolib.items import Wood

pole = entities.MediumElectricPole(
    position=Position(0.5, 0.5)
)

inserter = entities.Inserter(
    position=Position(5.5, 0.5)
)

# set the stack size to 1
inserter.override_stack_size(1)

# set the circuit condition to wood signal greater than 1337
inserter.circuit_condition(
    CircuitCondition(
        first_signal=Signal(Wood.name(), type="item"),
        constant=1337,
        comparator=">"
    )
)

# connect both entities by red wire
ConnectionMaker.make(inserter, pole, "red")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

factoriolib-0.0.2.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

factoriolib-0.0.2-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file factoriolib-0.0.2.tar.gz.

File metadata

  • Download URL: factoriolib-0.0.2.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.62.3 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for factoriolib-0.0.2.tar.gz
Algorithm Hash digest
SHA256 21885d813081b294b33f2cb0a99fa3ff6fb3ecd3d215fdb8ab4b6c9693cb53c1
MD5 badb6d2554a54107774d9ce4e1e817d0
BLAKE2b-256 aed6f06b5169b55b47993e2636b049a1138b0f5eda898365a00d0a73b7b79005

See more details on using hashes here.

File details

Details for the file factoriolib-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: factoriolib-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.62.3 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for factoriolib-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c4931e90dc93c959f3d5d6c43484a757e48b03c32997e086b51beec3695981b3
MD5 ee85e3d7602eb3d1ee3227430d1a9db3
BLAKE2b-256 253e2d3c8db4cc713413044f65551a1dd7ce2063e12269b1c3c7a0149f4f8cd7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page