From ef4f9628c8b5ea28b70a40212352dc1062b877f0 Mon Sep 17 00:00:00 2001 From: Andrew Miner Date: Mon, 12 Oct 2026 22:51:22 -0600 Subject: [PATCH] wip --- init.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index ca45e94..ff3249d 100644 --- a/init.lua +++ b/init.lua @@ -45,12 +45,11 @@ local function consolidate_stacks(stacks) end local function extract_inventory_stacks(inventory, skip_count) - skip_count = skip_count or 0 - local result = {} - local max_slots = inventory:get_size(MAIN) + local first_slot = 1 + (skip_count or 0) + local last_slot = inventory:get_size(MAIN) - for index = 1 + skip_count, max_slots do + for index = first_slot, last_slot do local stack = inventory:get_stack(MAIN, index) if stack == nil then goto continue end if stack:is_empty() then goto continue end @@ -71,10 +70,11 @@ local function get_human_name(stack) end local function inject_inventory(inventory, stacks, skip_count) - skip_count = skip_count or 0 + local first_index = 1 + (skip_count or 0) local last_index = inventory:get_size(MAIN) - for inv_index = 1 + skip_count, last_index do - inventory:set_stack(MAIN, inv_index, stacks[inv_index]) + for inv_index = first_index, last_index do + local stack_index = inv_index - first_index + 1 + inventory:set_stack(MAIN, inv_index, stacks[stack_index]) end end