Replies: 1 comment
-
Flipping belts on a per-entity basis can be achieved fairly easily: from draftsman.blueprintable import Blueprint
from draftsman.entity import new_entity
from draftsman.constants import Direction
bp_string = "..."
blueprint = Blueprint(bp_string)
# Simple inversion (might be nice to have a utility func for this)
direction_map = {
Direction.NORTH: Direction.SOUTH,
Direction.EAST: Direction.WEST,
Direction.SOUTH: Direction.NORTH,
Direction.WEST: Direction.EAST
}
for i, entity in enumerate(blueprint.entities):
if entity.type == "transport-belt":
new_direction = direction_map[entity.direction]
dict_results = entity.to_dict()
dict_results["direction"] = new_direction
blueprint.entities[i] = new_entity(**dict_results)
print(blueprint.to_string()) And slightly more succinctly with (if we skirt the no-replacement rule, which is valid in this context): for entity in blueprint.entities:
if entity.type == "transport-belt":
entity._direction = direction_map[entity.direction] Unforunately, this only acts as a naiive replacement and does not properly handle curves: Fixing this would require a more sophisticated routine, one that can recognize curved belts and swap them accordingly. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've got this setup to mine mixed belts at my current mining prod level:
I would like to take this chunk and reverse the belts so that I can get the same merging effect from the upper-left chunk of drills:
draftsman should support this already, I think.
Beta Was this translation helpful? Give feedback.
All reactions