diff --git a/changelog.txt b/changelog.txt index cbe93705..9789ad97 100644 --- a/changelog.txt +++ b/changelog.txt @@ -10,6 +10,7 @@ Date: ? - Buffed the fertilizer-2 recipe. guano 3 -> 1, ammonium-chloride 20 -> 2. - Deleted the micromine turd. - The micromine machine now has a fixed recipe for incubated petri dishes. + - The "transfer all items" caravan action will now preserve metadata for even more items such as equipment grids, blueprint data, and upgrade planner data. --------------------------------------------------------------------------------------------------- Version: 3.0.18 Date: 2024-11-7 diff --git a/scripts/caravan/caravan-prototypes.lua b/scripts/caravan/caravan-prototypes.lua index efaa0510..5e14ee95 100644 --- a/scripts/caravan/caravan-prototypes.lua +++ b/scripts/caravan/caravan-prototypes.lua @@ -140,13 +140,11 @@ end local function transfer_all_items(input_inventory, output_inventory) if input_inventory.is_empty() or output_inventory.is_full() then return end - for _, stack in pairs(input_inventory.get_contents()) do - if output_inventory.can_insert(stack) then - local inserted_count = output_inventory.insert(stack) - if inserted_count ~= 0 then - stack.count = inserted_count - input_inventory.remove(stack) - end + for i = 1, #input_inventory do + local stack = input_inventory[i] + local inserted_count = output_inventory.insert(stack) + if inserted_count ~= 0 then + stack.count = stack.count - inserted_count end end end