Rotatable labs?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Rotatable labs?

Post by Deadlock989 »

What makes an entity rotatable?

Crafting machines have support for Animation4Way in their main sprites and they become rotatable if crafting or energy source fluid boxes (a) exist and (b) if there are only crafting fluid boxes then either off_when_no_fluid_recipe is false or a fluid-using recipe is selected. Inserters are always rotatable and so their energy source fluid boxes rotate with them.

Labs, however, just have two Animations (on and off) for their main sprites. You can put fluid boxes in the energy source and it works - except that you don't seem to be able to rotate them, forcing you to have pipe connections in all four directions.

Is this just a hardcoded thing or have I missed a trick?
Image

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

Re: Rotatable labs?

Post by Bilka »

Whether an entity has directions (=is rotatable) is hardcoded internally. For the lab specifically, it doesn't do the "they become rotatable if [...] energy source fluid boxes exist" calculation that crafting machines do; it just never rotates.
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: Rotatable labs?

Post by Deadlock989 »

Thought so.

I guess there are options.

(1) Do nothing and just have four pipes sticking out of every steam lab.
(2a) Provide two versions of the lab to the player, horizontal and vertical.
(2b) Ditto but hide one from the player and provide a hacky control script method to "fake rotate" by switching the entities out alternately.

1 isn't actually so bad although I don't like the pipes sticking out into the tile where you want to put inserters. 2a seems a bit dumb and unlike anything else in the game. 2b is possible, I already do something similar for another entity (turret firing arc, not rotation), but in this case there doesn't seem to be support in the API for lab progress like there is for crafting machine and drill progress so it would be lost on rotation. You also can't catch the rotation event for an entity that doesn't, well, rotate, so you'd have to assign two custom key inputs that happened to have the same keys as the rotate keys and listen for those instead. You also wouldn't be able to rotate the lab in your hand before placement.

Anyone have a better idea?
Image

pleegwat
Filter Inserter
Filter Inserter
Posts: 258
Joined: Fri May 19, 2017 7:31 pm
Contact:

Re: Rotatable labs?

Post by pleegwat »

How about pass-through steam connections on all sides, like on the uranium miner? Of course this simplifies the player's routing puzzle as well since they would no longer need to route a separate pipe through each lab.

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

Re: Rotatable labs?

Post by Deadlock989 »

pleegwat wrote:
Sat Oct 24, 2020 3:16 pm
How about pass-through steam connections on all sides, like on the uranium miner? Of course this simplifies the player's routing puzzle as well since they would no longer need to route a separate pipe through each lab.
That is option 1 above. I don't really like it - the pipes stick out exactly where you want to put inserters. I mean, I'm being very anal here and can live with it.

(Miners only have pipe connections on 3 sides and can rotate).

steam-labs.jpg
steam-labs.jpg (776.2 KiB) Viewed 2055 times
Image

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

Re: Rotatable labs?

Post by Bilka »

Deadlock989 wrote:
Sat Oct 24, 2020 10:35 am
(2b) Ditto but hide one from the player and provide a hacky control script method to "fake rotate" by switching the entities out alternately.

[...] 2b is possible, I already do something similar for another entity (turret firing arc, not rotation), but in this case there doesn't seem to be support in the API for lab progress like there is for crafting machine and drill progress so it would be lost on rotation. You also can't catch the rotation event for an entity that doesn't, well, rotate, so you'd have to assign two custom key inputs that happened to have the same keys as the rotate keys and listen for those instead. You also wouldn't be able to rotate the lab in your hand before placement.
Lab progress bars are fake, so not being able to set them should be a purely graphical issue.
To do something on the same keybind as a built in hotkey, https://wiki.factorio.com/Prototype/Cus ... me_control can be used.
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: Rotatable labs?

Post by Deadlock989 »

Bilka wrote:
Sat Oct 24, 2020 4:04 pm
Lab progress bars are fake, so not being able to set them should be a purely graphical issue.
To do something on the same keybind as a built in hotkey, https://wiki.factorio.com/Prototype/Cus ... me_control can be used.
So the "progress" is all in the force research progress levels and the "current durability" of the science packs? If I carry the latter over to the new copy of the packs in the new entity, nothing is lost or gained?

Thanks for the linked hotkey tip, I didn't know you could do that.
Image

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

Re: Rotatable labs?

Post by Bilka »

Deadlock989 wrote:
Sat Oct 24, 2020 4:11 pm
So the "progress" is all in the force research progress levels and the "current durability" of the science packs? If I carry the latter over to the new copy of the packs in the new entity, nothing is lost or gained?
As far as I can see, yes. You should be able to easily carry over the science packs by fast-replacing the lab (fast_replace argument in create entity). That will also transfer modules and the content of the energy source (like fuel items), if present.
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: Rotatable labs?

Post by Deadlock989 »

Thanks, I will try it. It would still be weird to not be able to rotate it in your hand but it may be a price worth paying.
Image

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

Re: Rotatable labs?

Post by Deadlock989 »

No, no dice. Blueprint / copy-paste rotation doesn't work. You can preserve existing "orientations" (the north-south and east-west versions of the lab) in blueprints and have bots build them all with the same item but if you rotate the blueprint 90 degrees, all the connections are wrong.
Image

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Rotatable labs?

Post by darkfrei »

Hack: blueprintable must be placeholder with 4 orientations, on build replace with lab with same hardcoded orientation.

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

Re: Rotatable labs?

Post by Deadlock989 »

darkfrei wrote:
Mon Oct 26, 2020 11:46 am
Hack: blueprintable must be placeholder with 4 orientations, on build replace with lab with same hardcoded orientation.
Eh. How does on_built know that the blueprint was rotated?

Hacks = effort + breakable. I think I'm over it now, they can stick with 4-way connections, my solution was to throw more visual distraction at it so you don't have time to notice.


Image
Image

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Rotatable labs?

Post by darkfrei »

Deadlock989 wrote:
Mon Oct 26, 2020 1:03 pm
Eh. How does on_built know that the blueprint was rotated?
I don't like this solution. But there is no way to do it the right.

You can get the direction of the entity, delete it and place the lab with the same direction. Maybe also some hidden entity that makes nothing, but that goes to the blueprint. And it will be rotated with blueprint rotation.

Post Reply

Return to “Modding help”