InventoryPosition stack position is 0-based in BlueprintInsertPlan

We are aware of them, but they have low priority. We have more important things to do. They go here in order not to take space in the main bug thread list.
kajacx
Inserter
Inserter
Posts: 20
Joined: Sun Mar 10, 2019 11:08 am
Contact:

InventoryPosition stack position is 0-based in BlueprintInsertPlan

Post by kajacx »

When going through a logistic request's BlueprintInsertPlan, the "stack" slot number in InventoryPosition is 0-indexed, instead of 1-index.

Minimal reproducible example (control.lua):

Code: Select all

script.on_event({ defines.events.on_entity_settings_pasted },
function(event)
    local source = event.source
    local source_modules = source and source.get_module_inventory()
    
    if not source_modules then
        return
    end

    local target_requests = source.surface.find_entities_filtered({
        area = {
            { source.position.x - 0.01, source.position.y - 0.01 },
            { source.position.x + 0.01, source.position.y + 0.01 }
        },
        name = "item-request-proxy",
        force = source.force
    })
    
    for _, request in pairs(target_requests) do
        for _, insert in pairs(request.insert_plan) do
            for _, inserted_item in pairs(insert.items.in_inventory) do
                game.print("Slot " .. inserted_item.stack .. " has " .. insert.id.name)
            end
        end
    end
end)
Resulting output:
Image
Rseding91
Factorio Staff
Factorio Staff
Posts: 14884
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: InventoryPosition stack position is 0-based in BlueprintInsertPlan

Post by Rseding91 »

Thanks for the report. Given these strings are now in every blueprint string that contains modules created since space-age has been released... I suspect they might be stuck this way. I'm going to move this to minor issues unless another developer wants to make an attempt at migrating old strings and changing it for future things.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Minor issues”