LuaEntity.circuit_connected_entities is 0 when fast replacing

Bugs that are actually features.
Post Reply
Natha
Fast Inserter
Fast Inserter
Posts: 175
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

LuaEntity.circuit_connected_entities is 0 when fast replacing

Post by Natha »

When accessing LuaEntity.circuit_connected_entities.red/green or LuaEntity.circuit_connection_definitions in on_robot_mined_entity and on_pre_player_mined_item, the arrays of both are empty, but ONLY in case the player is fast replacing or the robot is upgrading this entity. In other cases (mining and deconstructing) the array is correct.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2244
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: LuaEntity.circuit_connected_entities is 0 when fast replacing

Post by boskid »

This... is annoying to fix. Entity fast replace is doing a copy settings from old entity to new entity so there is a short period of time where both entities exist at the same time: logic for fast replace is basically "1/ create new entity, 2/ transfer settings, 3/ mine old entity". The event for "on_pre_player_mined_item" is raised when old entity is being mined in step 3 but the wires were already moved to the new entity in the step 2. This will not be changed in 1.1.x for sure, and from what i see the same behavior is in the expansion branch. This behavior is not specific to wires, the same behavior can be also observed for chests fast replacing where the inventory reports empty during this event since all the items were already moved to the new entity. I am hesitating if this is even a bug, it is basically an inherent behavior of how fast replace is implemented. I think there should be on_built_entity raised immediately after which will point at the new entity that already has all wires.

Post Reply

Return to “Not a bug”