From 6e54f2b82081e5063c9bb3b90cf6e4ac13700d2d Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sun, 16 May 2021 19:56:35 +0200 Subject: [PATCH] Fix ta4 chest take_item bug --- basis/conf_inv.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/basis/conf_inv.lua b/basis/conf_inv.lua index 159a5f0..b5abce3 100644 --- a/basis/conf_inv.lua +++ b/basis/conf_inv.lua @@ -91,15 +91,15 @@ end function inv_lib.take_item(pos, inv, listname, num, stacks) local mem = techage.get_mem(pos) - local size = #stacks mem.ta_startpos = mem.ta_startpos or 1 - for idx = mem.ta_startpos, mem.ta_startpos + size do - idx = (idx % size) + 1 + local size = #stacks + for i = 1, size do + local idx = stacks[((i + mem.ta_startpos) % size) + 1] local stack = inv:get_stack(listname, idx) local taken = stack:take_item(num) if taken:get_count() > 0 then inv:set_stack(listname, idx, stack) - mem.ta_startpos = idx + mem.ta_startpos = mem.ta_startpos + i return taken end end