Fix ta4 chest take_item bug

master
Joachim Stolberg 2021-05-16 19:56:35 +02:00
parent 72d01ef925
commit 6e54f2b820
1 changed files with 4 additions and 4 deletions

View File

@ -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