Page 1 of 1

Rotatable labs?

Posted: Fri Oct 23, 2020 2:52 pm
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?

Re: Rotatable labs?

Posted: Fri Oct 23, 2020 3:28 pm
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.

Re: Rotatable labs?

Posted: Sat Oct 24, 2020 10:35 am
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?

Re: Rotatable labs?

Posted: Sat Oct 24, 2020 3:16 pm
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.

Re: Rotatable labs?

Posted: Sat Oct 24, 2020 3:24 pm
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 3099 times

Re: Rotatable labs?

Posted: Sat Oct 24, 2020 4:04 pm
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.

Re: Rotatable labs?

Posted: Sat Oct 24, 2020 4:11 pm
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.

Re: Rotatable labs?

Posted: Sat Oct 24, 2020 4:18 pm
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.

Re: Rotatable labs?

Posted: Sat Oct 24, 2020 4:21 pm
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.

Re: Rotatable labs?

Posted: Sat Oct 24, 2020 5:21 pm
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.

Re: Rotatable labs?

Posted: Mon Oct 26, 2020 11:46 am
by darkfrei
Hack: blueprintable must be placeholder with 4 orientations, on build replace with lab with same hardcoded orientation.

Re: Rotatable labs?

Posted: Mon Oct 26, 2020 1:03 pm
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

Re: Rotatable labs?

Posted: Mon Oct 26, 2020 4:43 pm
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.