Page 1 of 1

Can you make an entity with only 2 orientations?

Posted: Mon Jan 04, 2021 5:03 pm
by Kiplacon
Most entities either can't be rotated or have all 4 directions. Is there a way to make a custom entity with only 2 orientations, left and right? I know the steam engine has 2 orientations but those are vertical and horizontal meaning the collision box rotates with it too.

Re: Can you make an entity with only 2 orientations?

Posted: Tue Jan 05, 2021 1:16 pm
by Deadlock989
The only entity that I'm aware of that is possible to restrict to just 2 orientations (north and east apparently) is the storage tank entity, which has a specific property to enable that. As you say, most things either can't rotate at all or have 4 directions; there are a handful which can have 8 (rail tracks, rail signals, turrets).

Depending on what kind of entity it is that you want and what it does, you may be able to make a 4-way entity where the north-south and east-west orientations are functionally and visually identical, so it presents to the player as only having two.

Re: Can you make an entity with only 2 orientations?

Posted: Tue Jan 05, 2021 5:16 pm
by DaveMcW
Splitter also has 2 orientations.

Re: Can you make an entity with only 2 orientations?

Posted: Tue Jan 05, 2021 5:22 pm
by Deadlock989
DaveMcW wrote: Tue Jan 05, 2021 5:16 pm Splitter also has 2 orientations.
No, they have 4, which you can check with the entity tooltip debug info or just by rotating a splitter ghost in your hand. It's just that the rotation action from the hotkey after placement is locked to 180 degrees, which I think is the behaviour for anything that has a rectangular collision/selection box. That is different to a storage tank locked to two directions, which can never be put into a south or west orientation under any circumstance.

https://wiki.factorio.com/Prototype/Splitter

Re: Can you make an entity with only 2 orientations?

Posted: Wed Jan 06, 2021 1:59 am
by Kiplacon
Deadlock989 wrote: Tue Jan 05, 2021 1:16 pm The only entity that I'm aware of that is possible to restrict to just 2 orientations (north and east apparently) is the storage tank entity, which has a specific property to enable that.
That actually sounds pretty good, I can always swap out for the real entity I want with a script. Thanks a lot :)

Re: Can you make an entity with only 2 orientations?

Posted: Wed Jan 06, 2021 1:40 pm
by Kiplacon
Okay so it turns out the two directions are vertical and horizontal so it'll get rotated if it's a rectangle. Maybe I'll just try to keep it a square shape

Re: Can you make an entity with only 2 orientations?

Posted: Wed Jan 06, 2021 1:53 pm
by Deadlock989
I'm pretty sure it's assumed that for those entities that allow a rectangular shape, they have to have a horizontal and vertical version unless they are never built by a player. If for some reason you had an entity that was wider than it was tall but couldn't rotate, it would break blueprint rotation. I have a purely decorative 3x12 non-colliding entity where this is the case, but it doesn't matter because players can't unlock it without console commands - the collision box rotates correctly when the blueprint is rotated, but visually it's garbage. If it did collide and didn't rotate, the blueprint probably wouldn't be buildable in half of the rotations.

What is it that you're trying to make?

Re: Can you make an entity with only 2 orientations?

Posted: Thu Jan 07, 2021 2:30 pm
by Kiplacon
I'm trying to make a bridge in two parts: the ramp going up to bridge level, and the bridge section itself. I only want the bridge to be placeable going horizonally and naturally you would need a ramp going back down on the other side. I could make two separate non-rotatable ramp entities one sloping up and one sloping down, but for the slicker user experience it'd be nice to have just one ramp entity that can be rotated/flipped between the two directions while maintaining the same rectangular hitbox

Re: Can you make an entity with only 2 orientations?

Posted: Thu Jan 07, 2021 2:50 pm
by Deadlock989
Kiplacon wrote: Thu Jan 07, 2021 2:30 pm I'm trying to make a bridge in two parts: the ramp going up to bridge level, and the bridge section itself. I only want the bridge to be placeable going horizonally and naturally you would need a ramp going back down on the other side. I could make two separate non-rotatable ramp entities one sloping up and one sloping down, but for the slicker user experience it'd be nice to have just one ramp entity that can be rotated/flipped between the two directions while maintaining the same rectangular hitbox
OK ... I guess I don't understand why you don't also want a vertical bridge. Regardless, if we were still in 1.0, I would have suggested a SimpleEntityWithOwner that has two graphics variations and the random variation on placement turned off - SEWO variations are nicely preserved in ghosts/blueprints without any extra hassle, and you could intercept the rotate key to flip between the two variations if your entity was under the cursor. Unfortunately they were changed in 1.1 from having just one orientation to four, so they now rotate as well.

If I were doing this I'd just have a half-bridge entity with all four directions.

Re: Can you make an entity with only 2 orientations?

Posted: Thu Jan 07, 2021 2:58 pm
by Bilka
A solution for 1.1 for the proposed solution by Deadlock would be the "not-rotatable" entity prototype flag, to have only one direction on the entity.

Re: Can you make an entity with only 2 orientations?

Posted: Thu Jan 07, 2021 3:04 pm
by Deadlock989
Bilka wrote: Thu Jan 07, 2021 2:58 pm A solution for 1.1 for the proposed solution by Deadlock would be the "not-rotatable" entity prototype flag, to have only one direction on the entity.
Nice. I always forget about those flags.

Just tested that out - it still results in odd or even erratic/broken blueprints when the blueprint is rotated (if the non-rotated rectangular entity ends up overlapping with any other ghost, at least one ghost will be wiped out when the bots revive any of the overlapping ghosts). I'd still go for a four-directional entity if that was at all possible.

Re: Can you make an entity with only 2 orientations?

Posted: Tue Jan 12, 2021 7:58 am
by darkfrei
Maybe also the steam generator.


StorageTank#two_direction_only