directional

class DirectionalMixin(
direction=Direction.NORTH,
*,
extra_keys: dict[str, Any] | None = None,
)

Permits this entity to be able to specify its direction attribute, a discrete rotation value. Exactly how many directions an entity can occupy (no-rotation, 4-way, 8-way, 16-way) is determined via it’s flags.

All entities are directional, except for vehicle/rolling stock entities, which instead have an orientation.

See also

OrientationMixin

property collision_set_rotated : bool

Whether or not this entity actually has their collision set rotated by their direction. Some entities (such as rail signals) have many valid directions they can exist as but reuse the same collision set for all of them.

direction : Direction

Serialized

This attribute is imported/exported from blueprint strings.

The direction that the Entity is facing. An Entity’s “front” is usually the direction of it’s outputs, if it has any.

For some entities, this attribute may be redundant; for example, the direction value for an AssemblingMachine only matters if the machine has a fluid input or output.

Raises DirectionWarning if set to a direction not contained within valid_directions.

Raises:

DraftsmanError – If the direction is set while inside a Collection, and the target entity is both non-square and the particular rotation would change it’s apparent tile width and height. See, here for more info.

property valid_directions : set[Direction]

A set containing all directions that this entity can face. If direction is set to a direction not contained within this set, it is clamped to the nearest correct direction when imported into Factorio.