[1.1.70] on_built_entity reports incorrect belt_to_ground_type when dragging backwards

Bugs that are actually features.
Post Reply
heartosis
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sat Oct 01, 2022 3:57 am
Contact:

[1.1.70] on_built_entity reports incorrect belt_to_ground_type when dragging backwards

Post by heartosis »

I have a script that I add to control.lua while watching replays to dump what players are doing to the log to be able to simulate other players taking actions.

When players drag a belt backwards (e.g. the belt is pointing right but the player is dragging left) and it makes an underground belt, the "belt_to_ground_type" property is reversed on the underground belts in the "created_entity" in the "on_built_entity" event. In the example of dragging left, the right one is reported as an input while the left one is reported as an output. You can recreate this by running this script and dragging a belt backwards through an obstacle:

Code: Select all

/c script.on_event(defines.events.on_built_entity,
    function(event)
        if event.created_entity.type == "underground-belt" then
            game.print("pos = " ..serpent.line(event.created_entity.position) .. ", belt_to_ground_type = " .. event.created_entity.belt_to_ground_type)
        end
    end
)
Video demonstrating

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

Re: [1.1.70] on_built_entity reports incorrect belt_to_ground_type when dragging backwards

Post by boskid »

Thanks for the report however this is not a bug. Smart belt building logic for reverse drag that creates underground belts is implemented as 2 stages: first it builds undergrounds in a way they would connect correctly and then it adjusts their direction if they happened to be pointing wrong way. The event is simply raised before the direction adjustment happens. I am not sure if there are events raised during rotation. It is implemented that way because the code uses common code for building entities the same as player does and a player is unable to freely build an underground belt output without rotating underground or connecting to existing input underground.

Main issues with implementing this are related to creating pair of underground belts, for example in this case:
103790.png
103790.png (274.16 KiB) Viewed 434 times
By draggin west-facing belt to the east, regardless of which underground belt is placed first, it will immediately connect to the outer underground belt and it will have a correct type, but when dragging east-facing belt to the east, first underground created regardless of which one it is, it would be created with wrong direction that was deduced as opposite type of the existing entity it connects to. First entity cannot enforce type because it would rotate unrelated underground outside, and second underground built will connect to first underground which now has any type. Undergrounds must be rotated only when they are both already built as this is the only point in time when a rotation will not rotate unrelated entities outside

Post Reply

Return to “Not a bug”