Automatic Underground Pipe Connectors

by sparr

Automatically place a pipe when two undergrounds are placed at a corner or one space apart.

Utilities
2 months ago
1.0 - 2.0
16.2K

b Bug when copy pasting 2 underground pipes

2 months ago

The mod Automatic Underground Pipe Connectors (2.0.0) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event automatic-underground-pipe-connectors::on_built_entity (ID 6)
automatic-underground-pipe-connectors/control.lua:85: attempt to index a nil value
stack traceback:
automatic-underground-pipe-connectors/control.lua:85: in function <automatic-underground-pipe-connectors/control.lua:59>

2 months ago

I am able to copy and paste various configurations of two underground pipes without encountering this error. I tried the two pipes being together and far apart, and being close and far from existing pipes and pipe ghosts, and in positions that should or should not trigger the mod to add a pipe or pipe ghost.

Can you give more specific instructions for how to reproduce this error?

2 months ago

I can't reproduce this anymore. Super weird. I did restart the game since then. No idea what caused this, but I experienced this bug several times when copying any combinations of pipes.

2 months ago

I experienced the bug again today. Pasted a large blueprint with pipes and underground pipes in it. There is clearly some bug, and restarting the game fixes it temporarily. Not sure how I can help narrow it down.

2 months ago

Can you post a save and blueprint and tell me where to paste the blueprint to trigger the bug?

2 months ago

Paste the lone Game's Blueprint onto the pinned space platform :)

https://www.mediafire.com/file/hq429apoq13dnpu/on_built_entity_ID_6.zip/file

2 months ago

I am able to paste the blueprint onto the space platform with no error.

2 months ago

Can you unzip the mod and split up line 85 to get a more specific failure message?

change this:
placing_ghost = not game.players[event.player_index].get_main_inventory().find_item_stack(pipe_item_name)

to this:
local player = game.players[event.player_index]
local inventory = player.get_main_inventory()
local stack = inventory.find_item_stack(pipe_item_name)
placing_ghost = not stack

2 months ago

Although I can't reproduce it, I did add a nil check in the most likely place (player.get_main_inventory() returning nil). This will probably avoid the crash, but may cause unexpected misbehavior instead.

Are you playing in editor mode or some other mode that replaces the player with a different controller?

2 months ago

I swear it worked several times yesterday when I made the save but wouldn't today. Trying to rollback game version and or autosave I managed to trigger it again.

Error while running event automatic-underground-pipe-connectors::on_built_entity (ID 6)
automatic-underground-pipe-connectors/control.lua:87: attempt to index local 'inventory' (a nil value)
stack traceback:
automatic-underground-pipe-connectors/control.lua:87: in function <automatic-underground-pipe-connectors/control.lua:59

Line 87 being: local stack = inventory.find_item_stack(pipe_item_name).

And yes I have /editor active

2 months ago

OK, the latest version should fix that. I'm not sure why it was failing. Editor mode still has a non-nil get_main_inventory() for me.

2 months ago
(updated 2 months ago)

The mod Automatic Underground Pipe Connectors (2.0.1) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event automatic-underground-pipe-connectors::on_built_entity (ID 6)
automatic-underground-pipe-connectors/control.lua:226: attempt to index a nil value
stack traceback:
automatic-underground-pipe-connectors/control.lua:226: in function <automatic-underground-pipe-connectors/control.lua:59>

Save: https://www.mediafire.com/file/gge02n5f8fhf17f/ID6_autosave3_-_Copy.zip/file
Import string https://factorioprints.com/view/-OAcoeRGQtlWKk068F1L and paste it on the freshly launched 'BP T' platform, it reaches space a few seconds after loading the save.

Running v2.0.13, still trigger with only SA+requirement and this mod as the only actives ones

2 months ago

I think the root of the problem was building from map view. I've added another layer of fix in two places.

New response