Bugfix in compacting-storage.lua

This commit is contained in:
Emerson Rosen-Jones 2025-09-14 14:13:57 -04:00
parent 562303e98f
commit ca8d0fea41

View file

@ -133,19 +133,18 @@ function should_fill (type, counts)
end
if fill_src ~= nil and fill_dest ~= nil then break end
end
local amount_to_use = do
local ratio = AMOUNT_USED / AMOUNT_RETURNED
local amount_needed_src = nil
if fill_src == "block" then
amount_needed_src = amount_needed / ratio
else
amount_needed_src = amount_needed * ratio
end
if amount_needed_src < amount_spare then
return amount_needed_src
else
return amount_spare
end
local amount_to_use = nil
local ratio = AMOUNT_USED / AMOUNT_RETURNED
local amount_needed_src = nil
if fill_src == "block" then
amount_needed_src = amount_needed / ratio
else
amount_needed_src = amount_needed * ratio
end
if amount_needed_src < amount_spare then
amount_to_use = amount_needed_src
else
amount_to_use = amount_spare
end
return fill_dest, fill_src, amount_to_use
end