From add0ad14003214672a29d348ef4d581317d1f4a5 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Mon, 17 Nov 2025 20:29:26 -0500 Subject: [PATCH] compacting-storage.lua: more bugfixes and logic work --- compacting-storage.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index ef99774..f6dde82 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -108,7 +108,7 @@ function set_production (item_type, produce) ) local periph = string.format("redstone_relay_%d", relay_num) -- ON is disable production - if produce then print(("Producing %s"):format(item_type)) + if produce then print(("Producing %s"):format(item_type)) end peripheral.call(periph, "setOutput", face, not produce) end @@ -163,20 +163,20 @@ end function filter_clamp (diff, current_dist) -- reduce diff numbers to what can be crafted using current resources - local new_diff = { nuggets = 0, ingots = 0, blocks = 0 } if diff.blocks > 0 then - new_diff.blocks = math.min( - diff.blocks, + diff.blocks = math.min( + diff.blocks - (diff.blocks % BLOCK_RATIO), math.floor(current_dist.ingots / 9) ) end if diff.nuggets > 0 then - new_diff.nuggets = math.min( - diff.nuggets, + diff.nuggets = math.min( + diff.nuggets - (diff.nuggets % NUGGET_RATIO), current_dist.ingots * 9 ) end - new_diff.ingots = (new_diff.nuggets / 9) + (new_diff.blocks * 9) + diff.ingots = (-diff.nuggets / 9) + (-diff.blocks * 9) + return diff end function diff_to_crafts (diff)