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"}}
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.