Limit stack transfer

This commit is contained in:
Gabriel Tofvesson 2024-10-12 08:17:14 +02:00
parent 40213b6b18
commit 3a6cb08707

View File

@ -141,7 +141,7 @@ function ItemGroup:transferTo(target, itemCount)
local transferMax = math.min(itemCount or targetCap, targetCap, self:getItemCount())
local transfer = 0
for _,stack in targetGroup:_iterateStacks() do
if transfer == transferMax then
if transfer >= transferMax then
break
end
@ -150,7 +150,7 @@ function ItemGroup:transferTo(target, itemCount)
if stack:getCount() == targetCount then
goto continue
end
local _, xfer = from:transferTo(stack)
local _, xfer = from:transferTo(stack, targetCount - stack:getCount())
transfer = transfer + xfer
end
::continue::