Page 1 of 1

[2.0.47] Building from cursor in on_built_entity causes game to forget underground pipe dragging status

Posted: Mon Jun 02, 2025 5:07 pm
by sparr

Code: Select all

script.on_event(defines.events.on_built_entity, function(event) game.players[event.player_index].build_from_cursor{position={event.entity.position.x,event.entity.position.y-1}} end, {{filter="type",type="pipe-to-ground"}}
1. Install the above mod
2. Place a horizontal row of entities that can't be fast replaced by pipes, such as inserters or walls or assemblers. This step serves to allow the example mod to be simpler and is not otherwise relevant.
3. Two tiles below that row, place a west-facing underground pipe and keep the mouse button held down
4. Observe that the mod event causes an additional underground pipe to be placed north of the one you placed
5. Drag to the east
6. Observe that you are placing a new underground pipe every tile instead of the usual underground pipe dragging behavior

Note that this behavior persists even if the item built from the cursor is not an underground pipe. My actual mod swaps out the cursor stack, builds the new item from cursor, then swaps the underground pipe back into the cursor stack. The code here uses the existing cursor stack just to avoid a bunch of additional logic not relevant to the behavior in question.

Re: [2.0.47] Building from cursor in on_built_entity causes game to forget underground pipe dragging status

Posted: Mon Jun 02, 2025 6:02 pm
by Rseding91
Thanks for the report. This will be a “won’t fix”/“not a bug”. The issue is: calling build from cursor resets the last built entity which marks the active underground build operation as complete/invalid. The drag build logic is not setup to support what you’re trying to do and I’m not sure it ever will be.

Re: [2.0.47] Building from cursor in on_built_entity causes game to forget underground pipe dragging status

Posted: Tue Jun 03, 2025 5:21 pm
by sparr
A quick experiment suggests that having my event remove and re-build_from_cursor the original underground pipe produces good dragging behavior. I'll need to work around a lot of edge cases to make use of that, but it's probably better than giving up on build_from_cursor and going back to a pile of logic around the other placement check methods.