Can you make an entity with only 2 orientations?

Place to get help with not working mods / modding interface.
Post Reply
Kiplacon
Burner Inserter
Burner Inserter
Posts: 10
Joined: Tue Jan 16, 2018 8:14 pm
Contact:

Can you make an entity with only 2 orientations?

Post 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.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

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

Post 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.
Image

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

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

Post by DaveMcW »

Splitter also has 2 orientations.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

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

Post 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
Image

Kiplacon
Burner Inserter
Burner Inserter
Posts: 10
Joined: Tue Jan 16, 2018 8:14 pm
Contact:

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

Post 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 :)

Kiplacon
Burner Inserter
Burner Inserter
Posts: 10
Joined: Tue Jan 16, 2018 8:14 pm
Contact:

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

Post 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

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

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

Post 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?
Image

Kiplacon
Burner Inserter
Burner Inserter
Posts: 10
Joined: Tue Jan 16, 2018 8:14 pm
Contact:

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

Post 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

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

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

Post 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.
Image

Bilka
Factorio Staff
Factorio Staff
Posts: 3133
Joined: Sat Aug 13, 2016 9:20 am
Contact:

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

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

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

Post 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.
Image


Post Reply

Return to “Modding help”