[2.0.11] Buggy on_built_entity event for 'smart' underground belt placement
Posted: Wed Oct 30, 2024 7:50 am
on_built_entity has buggy behavior when pairs of underground belts are built using the new 'smart' belt logic, especially when one of the undergrounds is destroyed.
A short debug print function in control.lua:
When the pair of undergrounds is built, you expect this script event to trigger twice. But instead, you get one merged trigger of the event, somehow printing the event once but both the belts separately.
It gets even weirder when you add an entity.destroy() call, where it seems to bug out the second underground belt's construction, and the response is incomplete. Somehow now only the position gets printed, and the belt_to_ground_type of the second underground is gone. Since you don't get the info that the second belt is an output belt, belt directions are all wrong.
A short debug print function in control.lua:
Code: Select all
local function on_built_entity(event)
game.print(event.tick)
game.print(event.entity.name)
game.print(event.entity.position)
game.print(event.entity.belt_to_ground_type)
-- event.entity.destroy()
end
script.on_event(defines.events.on_built_entity, on_built_entity, {{filter="type", type="underground-belt"}})
When the pair of undergrounds is built, you expect this script event to trigger twice. But instead, you get one merged trigger of the event, somehow printing the event once but both the belts separately.
It gets even weirder when you add an entity.destroy() call, where it seems to bug out the second underground belt's construction, and the response is incomplete. Somehow now only the position gets printed, and the belt_to_ground_type of the second underground is gone. Since you don't get the info that the second belt is an output belt, belt directions are all wrong.