Description
When a player is placing an entity ghost in midst of transport belts while using super-forced build, the game automatically deconstructs underlying entities, and places down ghost undergrounds on either side of the newly-placed ghost entity in order to ensure the transport belt line is uninterrupted.However, while the relevant deconstruction-related events do seem to trigger (for surrounding and overlapping transport belts), and the build event (on_built_entity) does trigger for the entity player has placed down, the game does not seem to emit the build-related events (on_pre_built and on_built_entity) for the ghost underground belts.
Reproductions steps
- Set-up the control script with the following content:
Code: Select all
-- The following code was made to only handle ghost entities, it will crash with regular entities (due to lack of checks etc). local function on_pre_ghost_deconstructed(event) local entity = event.ghost if entity.name == "entity-ghost" then print(string.format("Deconstructed ghost: %s (%d) at %s", entity.ghost_name, entity.unit_number, serpent.line(entity.position))) else print(string.format("Deconstructed entity: %s (%d) at %s", entity.name, entity.unit_number, serpent.line(entity.position))) end end local function on_built_entity(event) local entity = event.entity if entity.name == "entity-ghost" then print(string.format("Constructed ghost: %s (%d) at %s", entity.ghost_name, entity.unit_number, serpent.line(entity.position))) else print(string.format("Constructed entity: %s (%d) at %s", entity.name, entity.unit_number, serpent.line(entity.position))) end end local function on_pre_build(event) local position = event.position print(string.format("Pre-build at: %s", serpent.line(position))) end script.on_event(defines.events.on_built_entity, on_built_entity) script.on_event(defines.events.on_pre_ghost_deconstructed, on_pre_ghost_deconstructed) script.on_event(defines.events.on_pre_build, on_pre_build)
- Start a new game.
- Put transport belt ghost into cursor.
- Place down a straight line of three transport belt ghosts.
- Rotate the held belt ghost in cursor by 90 degrees.
- Force-build a new transport belt ghost on top of the existing transport belt ghost in the middle.
- Observe entities created in the game.
- Observe the terminal output from the control script.
Expected results
- In step (7), the middle transport belt ghost is replaced by perpendicular transport belt ghost.
- In step (7), the left and right transport belt ghosts are replaced by matching underground belt ghosts.
- In step (8), the output is similar to (exact coordinates may differ, added some blank lines to make the output more readable):
Code: Select all
Pre-build at: {x = 1.5, y = 2.5} Constructed ghost: transport-belt (28) at {x = 1.5, y = 2.5} Pre-build at: {x = 2.5, y = 2.5} Constructed ghost: transport-belt (29) at {x = 2.5, y = 2.5} Pre-build at: {x = 3.5, y = 2.5} Constructed ghost: transport-belt (30) at {x = 3.5, y = 2.5} Pre-build at: {x = 2.5, y = 2.5} Deconstructed ghost: transport-belt (29) at {x = 2.5, y = 2.5} Deconstructed ghost: transport-belt (28) at {x = 1.5, y = 2.5} Deconstructed ghost: transport-belt (30) at {x = 3.5, y = 2.5} Constructed ghost: transport-belt (31) at {x = 2.5, y = 2.5} Pre-build at: {x = 1.5, y = 2.5} Constructed ghost: underground-belt (32) at {x = 1.5, y = 2.5} Pre-build at: {x = 3.5, y = 2.5} Constructed ghost: underground-belt (33) at {x = 3.5, y = 2.5}
Actual results
- PASS In step (7), the middle transport belt ghost is replaced by perpendicular transport belt ghost.
- PASS In step (7), the left and right transport belt ghosts are replaced by matching underground belt ghosts.
- FAIL In step (8), the output is similar to (exact coordinates may differ):
Code: Select all
Pre-build at: {x = 1.5, y = 2.5} Constructed ghost: transport-belt (28) at {x = 1.5, y = 2.5} Pre-build at: {x = 2.5, y = 2.5} Constructed ghost: transport-belt (29) at {x = 2.5, y = 2.5} Pre-build at: {x = 3.5, y = 2.5} Constructed ghost: transport-belt (30) at {x = 3.5, y = 2.5} Pre-build at: {x = 2.5, y = 2.5} Deconstructed ghost: transport-belt (29) at {x = 2.5, y = 2.5} Deconstructed ghost: transport-belt (28) at {x = 1.5, y = 2.5} Deconstructed ghost: transport-belt (30) at {x = 3.5, y = 2.5} Constructed ghost: transport-belt (31) at {x = 2.5, y = 2.5}
Additional information
This is the simplest possilbe set of reproduction steps, but I was able to reproduce the problem with non-transport-belt entities as well, such as stone furnaces etc. It is only important to use an entity that the underground belts can actually gap around.Similar problem can probably be observed with non-ghost entities in the way - although I have not tested relevant deconstruction events for those.
The unit numbers I used in the expected results have been picked up from the game console itself (just a simpe /c game.print(game.player.selected.unit_number)), and I have built the initial three belts from left to right (so I guess the ordering in that particular case kinda makes sense, based on sequences observed).