Page 1 of 1

[Klonan] [1.1.35] LuaPlayer::build_from_cursor with underground belts flipped

Posted: Thu Jul 01, 2021 12:14 pm
by sushi_eater
Setting LuaEntity.direction doesn't work on underground belts. It did work fine with Factorio 1.0. This breaks the Picker Extended ghost revival.

https://mods.factorio.com/mod/PickerExt ... 1f55147e34

Ghost revival is working around the strange 'build_from_cursor' behavior, which modifies the direction parameter based on whether the first or second underground is placed:

https://github.com/Nexela/PickerExtende ... eviver.lua

Re: [1.1.35] Setting direction on underground belts doesn't work

Posted: Thu Jul 01, 2021 3:37 pm
by boskid
As for LuaEntity::direction not working for underground belts, this was an intended change because there were desync possibilities and even more corner cases around changing underground belt direction, so i am not considering this to qualify for a bug. Intended way of changing underground belt direction on existing entity is by using LuaEntity::rotate() which is unable to cause those weird corner cases where an underground belt would be rotated by only 90deg.

For the second part i am not sure what is being complained here.

Re: [1.1.35] Setting direction on underground belts doesn't work

Posted: Thu Jul 01, 2021 5:11 pm
by sushi_eater
LuaEntity::rotate() doesn't rotate the underground. It toggles the underground between input and output. The chute orientation remains the same. As far as I can tell, there is currently no way to change the underground orientation.
boskid wrote:
Thu Jul 01, 2021 3:37 pm
For the second part i am not sure what is being complained here.
Place two undergrounds with 'build_from_cursor', both facing west (effectively half undergrounds). The first one will use the direction set in 'build_from_cursor'. The second one will be 180 degrees rotated relative to the direction set in the 'build_from_cursor' call. As far as I can tell, there is no API to determine the UI state, if it's set to build the first underground (which respects the direction) or if it's in build second underground state, which builds the 180 degrees rotated version.

Re: [1.1.35] Setting direction on underground belts doesn't work

Posted: Fri Jul 02, 2021 11:40 am
by sushi_eater
BTW, I can certainly understand that you may not want to support direction/orientation changes on underground belts. But 'build_from_cursor' should support placing them in a predictable manner that doesn't depend on hidden UI/player state.

Re: [1.1.35] Setting direction on underground belts doesn't work

Posted: Sat Jul 10, 2021 7:49 pm
by Honktown
Tested a work-around:
hand_and_cursor_stuff.lua
(970 Bytes) Downloaded 209 times
Even with clearing the cursor and putting the item back, the "hidden state" of "is this underground the other side and should be rotated on build_from_cursor" persists. Rotating doesn't change the "should the build_from_cursor direction be reversed" either, it only makes the directions the same or opposite (from cursor to build_from_cursor direction). There's also no ...reset or inconsistency when the belts are off-axis (building north/south but in cursor east/west).

An underground can be re-created with desired properties (direction, I/O + surface, force, player index / last user, e.g.) . It is worth mentioning if a belt I/O is rotated, the direction changes, even though one might think that since the "cover" and belt side are still in the same absolute locations, they wouldn't.

Re: [1.1.35] Setting direction on underground belts doesn't work

Posted: Sun Jul 11, 2021 3:17 pm
by Klonan
sushi_eater wrote:
Fri Jul 02, 2021 11:40 am
But 'build_from_cursor' should support placing them in a predictable manner that doesn't depend on hidden UI/player state.
Thanks for the report,
Its fixed for the next release
(It will just force the internal underground flip state to 'false' when using build_from_cursor)