[Pard] [2.0.47] Impossible to complete selection-tool usage in a simulation

i142857
Inserter
Inserter
Posts: 22
Joined: Mon Nov 04, 2024 9:56 am
Contact:

[Pard] [2.0.47] Impossible to complete selection-tool usage in a simulation

Post by i142857 »

Summary: When trying to "use" a custom selection tool in a simulation, it's possible to start and drag the tool, but "releasing" it does not work.

Repro

Option 1:
1a. install the attached mod in bugrepro.zip

Option 2:
1b. create a mod with the following data.lua

Code: Select all

data:extend {
    {
        type = "selection-tool",
        name = "my-selection-tool",
        select = {
            border_color = { r = 0.1, g = 0.1, b = 0.9, a = 0.5 },
            cursor_box_type = "entity",
            mode = { "buildable-type" },
        },
        alt_select = {
            border_color = { r = 0.1, g = 0.1, b = 0.9, a = 0.5 },
            cursor_box_type = "entity",
            mode = { "buildable-type" },
        },
        stack_size = 1,
        flags = { "not-stackable" },
        icon = "__base__/graphics/icons/parameter/parameter-0.png",
    },
    {
        type = "tips-and-tricks-item-category",
        name = "bug-repro-category",
        order = "a",
    },
    {
        type = "tips-and-tricks-item",
        name = "bug-repro",
        order = "a",
        category = "bug-repro-category",
        simulation = {
            init = [[
                local player = game.simulation.create_test_player { name = "buggy" }
                game.simulation.camera_player = player
                ]],
            update = [[
                if game.tick == 1 then
                    game.players[1].cursor_stack.set_stack("my-selection-tool")
                elseif game.tick == 2 then
                    -- game.simulation.mouse_down()
                    game.simulation.control_down { control = "select-for-blueprint", notify = false }
                elseif game.tick < 200 then
                    game.simulation.move_cursor{position={5, 5}}
                elseif game.tick == 200 then
                    -- game.simulation.mouse_up()
                    game.simulation.control_up { control = "select-for-blueprint", notify = false }
                end
                ]],
        }
    },
}
2. create a new game
3. open tips and tricks and click on the first item (with unknown label, repro mod doesn't have locale)

Expected: the simulation drags a square blue selection box (corresponding to my-selection-tool), then "releases" the selection.
Actual: the simulation drags a square blue selection box, but it never gets released

Notes:
The bug happens whether you call game.simulation.mouse_down/mouse_up or control_down/control_up (see the commented out code above). The selection tool works normally in the real game.

Thank you for your time!
Attachments
factorio-current.log
(7.71 KiB) Downloaded 14 times
bugrepro.zip
(1.17 KiB) Downloaded 12 times
robot256
Smart Inserter
Smart Inserter
Posts: 1177
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [Pard] [2.0.47] Impossible to complete selection-tool usage in a simulation

Post by robot256 »

I think I found this behavior as well when I was writing simulations for Vehicle Wagon. I ended up writing scripts to emulate the visual effects of what completing rhe selection would have done. Will be interested to see if a better way can be found.
Post Reply

Return to “Assigned”