From 55635e4b644fff01978dcf1e000da2c068f2cf96 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Sat, 3 Jan 2026 20:17:27 -0500 Subject: [PATCH 01/23] misc: set goals for update --- compacting-storage.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compacting-storage.lua b/compacting-storage.lua index 363b665..beca343 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -7,6 +7,8 @@ -- constants local INVENTORY = "left" +local MAIN_TICKER = "" +local REQUEST_TICKER = "" local SLEEP_TIME = 30 local NUGGET_RATIO = 63 -- amount of nuggets per craft local BLOCK_RATIO = 7 -- amount of blocks per craft @@ -17,6 +19,14 @@ local NUGGETS = 1 local INGOTS = 9 local BLOCKS = 81 +-- V2!! what am i working on? +-- TODO new oregen interop: request from REQUEST_TICKER to get new ore +-- TODO new way to keep items stocked: request from MAIN_TICKER +-- do I even need a specific inventory anymore? I could maybe move metals +-- into the sophisticated storage setup. +-- TODO new way to craft between states: make requests with MAIN_TICKER +-- (could maybe add a redstone requester if desired) + -- Levels local MIN_NUM = (4 * STACKS * NUGGETS) + (4 * STACKS * INGOTS) local MAX_NUM = (8 * STACKS * NUGGETS) + (8 * STACKS * INGOTS) From 25eae158b1e9898408a34a1ed11bae78297471cf Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Sat, 3 Jan 2026 20:23:31 -0500 Subject: [PATCH 02/23] misc: demo old code --- compacting-storage.lua | 64 +++++------------------------------------- 1 file changed, 7 insertions(+), 57 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index beca343..99df3ac 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -31,51 +31,9 @@ local BLOCKS = 81 local MIN_NUM = (4 * STACKS * NUGGETS) + (4 * STACKS * INGOTS) local MAX_NUM = (8 * STACKS * NUGGETS) + (8 * STACKS * INGOTS) --- TODO map targets to specific relays and faces --- Key - 1: nuggets_to_ingots, 2: ingots_to_blocks, 3: blocks_to_ingots, --- 4: ingots_to_nuggets, 5: enable/disable production -local target = {} -target.iron = {} -target.iron[1] = "0:front" -target.iron[2] = "0:top" -target.iron[3] = "0:back" -target.iron[4] = "16:front" -target.iron[5] = "17:back" -target.copper = {} -target.copper[1] = "1:front" -target.copper[2] = "1:top" -target.copper[3] = "1:back" -target.copper[4] = "16:top" -target.copper[5] = "18:front" -target.zinc = {} -target.zinc[1] = "2:front" -target.zinc[2] = "2:top" -target.zinc[3] = "2:back" -target.zinc[4] = "16:back" -target.zinc[5] = "18:top" -target.gold = {} -target.gold[1] = "3:front" -target.gold[2] = "3:top" -target.gold[3] = "3:back" -target.gold[4] = "17:front" -target.gold[5] = "18:back" -target.electrum = {} -target.electrum[1] = "4:front" -target.electrum[2] = "4:top" -target.electrum[3] = "4:back" -target.electrum[4] = "17:top" - -- basic actions function craft (item_type, conversion_type) - -- TODO double check this - local relay_num, face = string.match( - target[item_type][conversion_type], - "(%d+):(%l+)" - ) - local periph = string.format("redstone_relay_%d", relay_num) - peripheral.call(periph, "setOutput", face, true) - os.sleep(0.1) - peripheral.call(periph, "setOutput", face, false) + -- TODO rework end function craft_multiple (item_type, conversion_type, count) @@ -107,17 +65,8 @@ function execute_crafts (item_type, crafts) end end -function set_production (item_type, produce) - local target_string = target[item_type][5] - if target_string == nil then return end - local relay_num, face = string.match( - target_string, - "(%d+):(%l+)" - ) - local periph = string.format("redstone_relay_%d", relay_num) - -- ON is disable production - if produce then print(("Producing %s"):format(item_type)) end - peripheral.call(periph, "setOutput", face, not produce) +function request_more (item_type, amt) + -- TODO end -- logic @@ -136,6 +85,7 @@ function dist_to_num (dist) end function get_dist (item_type, items) + -- TODO redo, incorporate sum_items. DRY! local dist = { nuggets = 0, ingots = 0, blocks = 0 } for item, count in pairs(items) do local type, form = item:match":(%l-)_(%l*)" @@ -188,7 +138,6 @@ function filter_clamp (diff, current_dist) end function diff_to_crafts (diff) - -- TODO double-check this one -- go from one end e.g. nuggets to the other e.g. blocks, removing -- from the diff to create crafts until the diff is empty local crafts = {} @@ -215,7 +164,6 @@ while true do for _, item_type in ipairs(ITEM_TYPES) do local current_dist = get_dist(item_type, items) local num = dist_to_num(current_dist) - if num > MAX_NUM then set_production(item_type, false) end if num > MIN_NUM then local desired_dist = decide_dist(num) local diff = get_diff(desired_dist, current_dist) @@ -223,7 +171,9 @@ while true do local crafts = diff_to_crafts(diff) execute_crafts(item_type, crafts) else - set_production(item_type, true) + -- TODO + -- TODO potentially keep requesting until above MAX_NUM + request_more(item_type, amt) end end From 3fb955bf0f9d4787f7baa6c6ae83ddab7acc3481 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Fri, 16 Jan 2026 18:20:44 -0500 Subject: [PATCH 03/23] feat: change config format --- compacting-storage.lua | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 99df3ac..eaf81ec 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -12,7 +12,33 @@ local REQUEST_TICKER = "" local SLEEP_TIME = 30 local NUGGET_RATIO = 63 -- amount of nuggets per craft local BLOCK_RATIO = 7 -- amount of blocks per craft -local ITEM_TYPES = { "iron", "copper", "zinc", "gold", "electrum" } +local ITEM_TYPES = { + iron = { + nugget = "minecraft", + ingot = "minecraft", + block = "minecraft", + }, + copper = { + nugget = "create", + ingot = "minecraft", + block = "minecraft", + }, + zinc = { + nugget = "create", + ingot = "create", + block = "create", + }, + gold = { + nugget = "minecraft", + ingot = "minecraft", + block = "minecraft", + }, + electrum = { + nugget = "createaddition", + ingot = "createaddition", + block = "createaddition", + }, +} local STACKS = 64 local NUGGETS = 1 From ecb7ff7c407de37d1c851e30f620b2a0f58b2076 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Fri, 16 Jan 2026 21:55:07 -0500 Subject: [PATCH 04/23] revert: last commit --- compacting-storage.lua | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index eaf81ec..99df3ac 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -12,33 +12,7 @@ local REQUEST_TICKER = "" local SLEEP_TIME = 30 local NUGGET_RATIO = 63 -- amount of nuggets per craft local BLOCK_RATIO = 7 -- amount of blocks per craft -local ITEM_TYPES = { - iron = { - nugget = "minecraft", - ingot = "minecraft", - block = "minecraft", - }, - copper = { - nugget = "create", - ingot = "minecraft", - block = "minecraft", - }, - zinc = { - nugget = "create", - ingot = "create", - block = "create", - }, - gold = { - nugget = "minecraft", - ingot = "minecraft", - block = "minecraft", - }, - electrum = { - nugget = "createaddition", - ingot = "createaddition", - block = "createaddition", - }, -} +local ITEM_TYPES = { "iron", "copper", "zinc", "gold", "electrum" } local STACKS = 64 local NUGGETS = 1 From 4481b8e7fa82a4e3604527baed175e1cd7487b1d Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Fri, 16 Jan 2026 21:55:56 -0500 Subject: [PATCH 05/23] feat: change sum_items for stock ticker --- compacting-storage.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 99df3ac..7d46c52 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -71,9 +71,9 @@ end -- logic -function sum_items (inv) +function sum_items (inv_f) local result = {} - for _, item in pairs(inv.list()) do + for _, item in pairs(inv_f()) do if result[item.name] == nil then result[item.name] = 0 end result[item.name] = result[item.name] + item.count end @@ -156,8 +156,9 @@ function print_counts (items) end while true do + local main_inv = peripheral.wrap(MAIN_TICKER) -- 1. Sum items in inventory and organize by item type - local items = sum_items(peripheral.wrap(INVENTORY)) + local items = sum_items(main_inv.stock) -- print_counts(items) -- 2. either work towards a desired distribution or create more resources From 9b17cd22fe3de2a4dd1cdc7a2daab7d4dca86f45 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Fri, 16 Jan 2026 21:56:31 -0500 Subject: [PATCH 06/23] misc: change todo --- compacting-storage.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 7d46c52..07d9ca9 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -85,7 +85,7 @@ function dist_to_num (dist) end function get_dist (item_type, items) - -- TODO redo, incorporate sum_items. DRY! + -- TODO change plurals to singulars to match mc local dist = { nuggets = 0, ingots = 0, blocks = 0 } for item, count in pairs(items) do local type, form = item:match":(%l-)_(%l*)" From c7257114efbc6c1b2964e4c0c6bb1ccac0f1fcc0 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Fri, 16 Jan 2026 22:01:46 -0500 Subject: [PATCH 07/23] feat: implement new request_more --- compacting-storage.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 07d9ca9..97481ec 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -9,6 +9,7 @@ local INVENTORY = "left" local MAIN_TICKER = "" local REQUEST_TICKER = "" +local STORAGE_ADDRESS = "" local SLEEP_TIME = 30 local NUGGET_RATIO = 63 -- amount of nuggets per craft local BLOCK_RATIO = 7 -- amount of blocks per craft @@ -65,8 +66,14 @@ function execute_crafts (item_type, crafts) end end -function request_more (item_type, amt) - -- TODO +function request_more (ticker, item_type) + local request = { + name = { + _op = "regex", + value = ".*:" .. item_type .. "_nugget" + } + } + ticker.requestFiltered(STORAGE_ADDRESS, request) end -- logic @@ -174,7 +181,7 @@ while true do else -- TODO -- TODO potentially keep requesting until above MAX_NUM - request_more(item_type, amt) + request_more(main_inv, item_type) end end From 95ba99477766103a545b345899fe9038752424a1 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Fri, 16 Jan 2026 22:02:01 -0500 Subject: [PATCH 08/23] chore: remove unused variable --- compacting-storage.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 97481ec..276da79 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -6,7 +6,6 @@ -- constants -local INVENTORY = "left" local MAIN_TICKER = "" local REQUEST_TICKER = "" local STORAGE_ADDRESS = "" From cc95868b29e3f522fc8713e332cd87e589466cce Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Fri, 16 Jan 2026 22:03:03 -0500 Subject: [PATCH 09/23] fix: only allocate main_inv once --- compacting-storage.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 276da79..1bc49a6 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -161,8 +161,8 @@ function print_counts (items) end end +local main_inv = peripheral.wrap(MAIN_TICKER) while true do - local main_inv = peripheral.wrap(MAIN_TICKER) -- 1. Sum items in inventory and organize by item type local items = sum_items(main_inv.stock) -- print_counts(items) From 378f44a9777073dc8ca8f5b314b20cf0a6ab3de8 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Fri, 16 Jan 2026 22:03:42 -0500 Subject: [PATCH 10/23] fix: use request ticker for requests --- compacting-storage.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 1bc49a6..0fed021 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -162,6 +162,7 @@ function print_counts (items) end local main_inv = peripheral.wrap(MAIN_TICKER) +local request_t = peripheral.wrap(REQUEST_TICKER) while true do -- 1. Sum items in inventory and organize by item type local items = sum_items(main_inv.stock) @@ -180,7 +181,7 @@ while true do else -- TODO -- TODO potentially keep requesting until above MAX_NUM - request_more(main_inv, item_type) + request_more(request_t, item_type) end end From 256b3779ed7781ad66cd180000cf585e925432ed Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Fri, 16 Jan 2026 22:04:29 -0500 Subject: [PATCH 11/23] misc: name main ticker better --- compacting-storage.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 0fed021..9390591 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -161,11 +161,11 @@ function print_counts (items) end end -local main_inv = peripheral.wrap(MAIN_TICKER) +local main_t = peripheral.wrap(MAIN_TICKER) local request_t = peripheral.wrap(REQUEST_TICKER) while true do -- 1. Sum items in inventory and organize by item type - local items = sum_items(main_inv.stock) + local items = sum_items(main_t.stock) -- print_counts(items) -- 2. either work towards a desired distribution or create more resources From acdd22bd1f75bacd9b10fdefb3a3b2e159e1401a Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Fri, 16 Jan 2026 22:05:57 -0500 Subject: [PATCH 12/23] feat: keep requesting until above MAX_NUM --- compacting-storage.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 9390591..272660e 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -163,6 +163,7 @@ end local main_t = peripheral.wrap(MAIN_TICKER) local request_t = peripheral.wrap(REQUEST_TICKER) +local requesting = {} while true do -- 1. Sum items in inventory and organize by item type local items = sum_items(main_t.stock) @@ -178,9 +179,13 @@ while true do diff = filter_clamp(diff, current_dist) local crafts = diff_to_crafts(diff) execute_crafts(item_type, crafts) + elseif num > MAX_NUM then + -- keep requesting until above MAX_NUM + requesting[item_type] = nil else - -- TODO - -- TODO potentially keep requesting until above MAX_NUM + requesting[item_type] = true + end + if requesting[item_type] then request_more(request_t, item_type) end end From ceca1b3d60cae8907a1b5789a5f74165e51e4ffb Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Fri, 16 Jan 2026 23:34:56 -0500 Subject: [PATCH 13/23] misc: update progress --- compacting-storage.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 272660e..3996c68 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -20,10 +20,7 @@ local INGOTS = 9 local BLOCKS = 81 -- V2!! what am i working on? --- TODO new oregen interop: request from REQUEST_TICKER to get new ore --- TODO new way to keep items stocked: request from MAIN_TICKER --- do I even need a specific inventory anymore? I could maybe move metals --- into the sophisticated storage setup. +-- DONE new oregen interop: request from REQUEST_TICKER to get new ore -- TODO new way to craft between states: make requests with MAIN_TICKER -- (could maybe add a redstone requester if desired) From 47c3db46f94858e7e022a8ce3a9d48f7a8b129b1 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Sat, 17 Jan 2026 16:30:43 -0500 Subject: [PATCH 14/23] feat: add crafting requester --- compacting-storage.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compacting-storage.lua b/compacting-storage.lua index 3996c68..d138d12 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -9,6 +9,7 @@ local MAIN_TICKER = "" local REQUEST_TICKER = "" local STORAGE_ADDRESS = "" +local CRAFTING_REQUESTER = "" local SLEEP_TIME = 30 local NUGGET_RATIO = 63 -- amount of nuggets per craft local BLOCK_RATIO = 7 -- amount of blocks per craft @@ -160,6 +161,8 @@ end local main_t = peripheral.wrap(MAIN_TICKER) local request_t = peripheral.wrap(REQUEST_TICKER) +local craft_requester = peripheral.wrap(CRAFTING_REQUESTER) +craft_requester.setConfiguration("strict") local requesting = {} while true do -- 1. Sum items in inventory and organize by item type From fa433f3c6243e0e3c518939c786da148082ce82f Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Sat, 17 Jan 2026 16:32:14 -0500 Subject: [PATCH 15/23] feat: start craft function --- compacting-storage.lua | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index d138d12..07d31da 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -10,6 +10,8 @@ local MAIN_TICKER = "" local REQUEST_TICKER = "" local STORAGE_ADDRESS = "" local CRAFTING_REQUESTER = "" +local COMPACTING_ADDR = "" +local UNPACKING_ADDR = "" local SLEEP_TIME = 30 local NUGGET_RATIO = 63 -- amount of nuggets per craft local BLOCK_RATIO = 7 -- amount of blocks per craft @@ -30,21 +32,33 @@ local MIN_NUM = (4 * STACKS * NUGGETS) + (4 * STACKS * INGOTS) local MAX_NUM = (8 * STACKS * NUGGETS) + (8 * STACKS * INGOTS) -- basic actions -function craft (item_type, conversion_type) - -- TODO rework +function craft (requester, item_type, conversion_type) + -- conversion_type key: 1, nuggets to ingots; 2, ingots to blocks; + -- 3, blocks to ingots; 4, ingots to nuggets + -- TODO find name + local compacting = conversion_type <= 2 + local count, address + if compacting then + count = NUGGET_RATIO + address = COMPACTING_ADDR + else + count = BLOCK_RATIO end + address = UNPACKING_ADDR + end + requester.setRequest({ name, count }) end -function craft_multiple (item_type, conversion_type, count) +function craft_multiple (requester, item_type, conversion_type, count) if count < 1 then return else - craft(item_type, conversion_type) + craft(requester, item_type, conversion_type) os.sleep(1) - return craft_multiple(item_type, conversion_type, count - 1) + return craft_multiple(requester, item_type, conversion_type, count - 1) end end -function execute_crafts (item_type, crafts) +function execute_crafts (requester, item_type, crafts) local num_crafts = crafts.nuggets if num_crafts > 0 then print(("Crafting %s nuggets"):format(item_type)) @@ -56,7 +70,7 @@ function execute_crafts (item_type, crafts) num_crafts = crafts.blocks if num_crafts > 0 then print(("Crafting %s blocks"):format(item_type)) - craft_multiple(item_type, 2, num_crafts) + craft_multiple(requester, item_type, 2, num_crafts) elseif num_crafts < 0 then print(("Crafting %s ingots"):format(item_type)) craft_multiple(item_type, 3, -num_crafts) @@ -178,7 +192,7 @@ while true do local diff = get_diff(desired_dist, current_dist) diff = filter_clamp(diff, current_dist) local crafts = diff_to_crafts(diff) - execute_crafts(item_type, crafts) + execute_crafts(craft_requester, item_type, crafts) elseif num > MAX_NUM then -- keep requesting until above MAX_NUM requesting[item_type] = nil From 2e424a2cdad08bbfe36619a961d161c3d5dd9444 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Sat, 17 Jan 2026 16:32:56 -0500 Subject: [PATCH 16/23] chore: align variable names Changes STORAGE_ADDRESS to STORAGE_ADDR to match the other addresses. --- compacting-storage.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 07d31da..4058bf9 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -8,8 +8,8 @@ local MAIN_TICKER = "" local REQUEST_TICKER = "" -local STORAGE_ADDRESS = "" local CRAFTING_REQUESTER = "" +local STORAGE_ADDR = "" local COMPACTING_ADDR = "" local UNPACKING_ADDR = "" local SLEEP_TIME = 30 @@ -84,7 +84,7 @@ function request_more (ticker, item_type) value = ".*:" .. item_type .. "_nugget" } } - ticker.requestFiltered(STORAGE_ADDRESS, request) + ticker.requestFiltered(STORAGE_ADDR, request) end -- logic From a53c0b750834707bbe50ab3f331fd8c62a3c9040 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Sat, 17 Jan 2026 16:34:13 -0500 Subject: [PATCH 17/23] feat: new config format This reverts commit ecb7ff7c407de37d1c851e30f620b2a0f58b2076. It also integrates the new config somewhat --- compacting-storage.lua | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 4058bf9..37d5bf2 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -15,7 +15,33 @@ local UNPACKING_ADDR = "" local SLEEP_TIME = 30 local NUGGET_RATIO = 63 -- amount of nuggets per craft local BLOCK_RATIO = 7 -- amount of blocks per craft -local ITEM_TYPES = { "iron", "copper", "zinc", "gold", "electrum" } +local ITEM_TYPES = { + iron = { + nugget = "minecraft", + ingot = "minecraft", + block = "minecraft", + }, + copper = { + nugget = "create", + ingot = "minecraft", + block = "minecraft", + }, + zinc = { + nugget = "create", + ingot = "create", + block = "create", + }, + gold = { + nugget = "minecraft", + ingot = "minecraft", + block = "minecraft", + }, + electrum = { + nugget = "createaddition", + ingot = "createaddition", + block = "createaddition", + }, +} local STACKS = 64 local NUGGETS = 1 @@ -184,7 +210,7 @@ while true do -- print_counts(items) -- 2. either work towards a desired distribution or create more resources - for _, item_type in ipairs(ITEM_TYPES) do + for item_type, _ in pairs(ITEM_TYPES) do local current_dist = get_dist(item_type, items) local num = dist_to_num(current_dist) if num > MIN_NUM then From 94dfe3c2b8f0aca3c707699b764418e0015b2d10 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Sat, 17 Jan 2026 16:53:25 -0500 Subject: [PATCH 18/23] feat: new getName table Table of utility functions --- compacting-storage.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/compacting-storage.lua b/compacting-storage.lua index 37d5bf2..ea4cc06 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -57,6 +57,27 @@ local BLOCKS = 81 local MIN_NUM = (4 * STACKS * NUGGETS) + (4 * STACKS * INGOTS) local MAX_NUM = (8 * STACKS * NUGGETS) + (8 * STACKS * INGOTS) +local getName = { + nugget = function (item_type) + return ("%s:%s_nugget"):format( + ITEM_TYPES[item_type].nugget, + item_type, + ) + end, + ingot = function (item_type) + return ("%s:%s_ingot"):format( + ITEM_TYPES[item_type].ingot, + item_type, + ) + end, + block = function (item_type) + return ("%s:%s_block"):format( + ITEM_TYPES[item_type].block, + item_type, + ) + end, +} + -- basic actions function craft (requester, item_type, conversion_type) -- conversion_type key: 1, nuggets to ingots; 2, ingots to blocks; From 4c7eaf14e9a27d9c8168f640f6cd0361c327a27d Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Sat, 17 Jan 2026 16:54:12 -0500 Subject: [PATCH 19/23] feat: use getName to find names of items --- compacting-storage.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index ea4cc06..2a5cc0e 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -82,7 +82,13 @@ local getName = { function craft (requester, item_type, conversion_type) -- conversion_type key: 1, nuggets to ingots; 2, ingots to blocks; -- 3, blocks to ingots; 4, ingots to nuggets - -- TODO find name + local convert = { + getName.nugget, + getName.ingot, + getName.block, + getName.ingot, + } + local name = convert[conversion_type](item_type) local compacting = conversion_type <= 2 local count, address if compacting then @@ -125,13 +131,7 @@ function execute_crafts (requester, item_type, crafts) end function request_more (ticker, item_type) - local request = { - name = { - _op = "regex", - value = ".*:" .. item_type .. "_nugget" - } - } - ticker.requestFiltered(STORAGE_ADDR, request) + ticker.requestFiltered(STORAGE_ADDR, { name = getName.nugget(item_type) }) end -- logic From bcb70f8780f7bf5820dc0428b6ed6706494f69b2 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Sat, 17 Jan 2026 16:54:53 -0500 Subject: [PATCH 20/23] misc: remove completed goals --- compacting-storage.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 2a5cc0e..efc63b6 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -48,11 +48,6 @@ local NUGGETS = 1 local INGOTS = 9 local BLOCKS = 81 --- V2!! what am i working on? --- DONE new oregen interop: request from REQUEST_TICKER to get new ore --- TODO new way to craft between states: make requests with MAIN_TICKER --- (could maybe add a redstone requester if desired) - -- Levels local MIN_NUM = (4 * STACKS * NUGGETS) + (4 * STACKS * INGOTS) local MAX_NUM = (8 * STACKS * NUGGETS) + (8 * STACKS * INGOTS) From 367744fdd6739534719a5c9dca105bf670cb5472 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Sat, 17 Jan 2026 16:58:10 -0500 Subject: [PATCH 21/23] chore: change plural item forms to match mc E.g. "ingots" to "ingot" --- compacting-storage.lua | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index efc63b6..8fdd2dd 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -107,7 +107,7 @@ function craft_multiple (requester, item_type, conversion_type, count) end function execute_crafts (requester, item_type, crafts) - local num_crafts = crafts.nuggets + local num_crafts = crafts.nugget if num_crafts > 0 then print(("Crafting %s nuggets"):format(item_type)) craft_multiple(item_type, 4, num_crafts) @@ -115,7 +115,7 @@ function execute_crafts (requester, item_type, crafts) print(("Crafting %s ingots"):format(item_type)) craft_multiple(item_type, 1, -num_crafts) end - num_crafts = crafts.blocks + num_crafts = crafts.block if num_crafts > 0 then print(("Crafting %s blocks"):format(item_type)) craft_multiple(requester, item_type, 2, num_crafts) @@ -141,12 +141,12 @@ function sum_items (inv_f) end function dist_to_num (dist) - return dist.nuggets + dist.ingots * INGOTS + dist.blocks * BLOCKS + return dist.nugget + dist.ingot * INGOTS + dist.block * BLOCKS end function get_dist (item_type, items) -- TODO change plurals to singulars to match mc - local dist = { nuggets = 0, ingots = 0, blocks = 0 } + local dist = { nugget = 0, ingot = 0, block = 0 } for item, count in pairs(items) do local type, form = item:match":(%l-)_(%l*)" form = string.format("%ss", form) @@ -158,42 +158,42 @@ function get_dist (item_type, items) end function decide_dist (num) - local dist = { nuggets = 0, ingots = 0, blocks = 0 } + local dist = { nugget = 0, ingot = 0, block = 0 } if num > MAX_NUM then local excess = num - MAX_NUM - dist.blocks = math.floor(excess / BLOCKS) - num = num - (dist.blocks * BLOCKS) + dist.block = math.floor(excess / BLOCKS) + num = num - (dist.block * BLOCKS) end local balance = math.floor(num / 10) - dist.nuggets, dist.ingots = balance, balance + dist.nugget, dist.ingot = balance, balance num = num - (balance * 10) - dist.nuggets = dist.nuggets + num + dist.nugget = dist.nugget + num return dist end function get_diff (dist1, dist2) return { - nuggets = dist1.nuggets - dist2.nuggets, - ingots = dist1.ingots - dist2.ingots, - blocks = dist1.blocks - dist2.blocks + nugget = dist1.nugget - dist2.nugget, + ingot = dist1.ingot - dist2.ingot, + block = dist1.block - dist2.block } end function filter_clamp (diff, current_dist) -- reduce diff numbers to what can be crafted using current resources - if diff.blocks > 0 then - diff.blocks = math.min( - diff.blocks - (diff.blocks % BLOCK_RATIO), - math.floor(current_dist.ingots / 9) + if diff.block > 0 then + diff.block = math.min( + diff.block - (diff.block % BLOCK_RATIO), + math.floor(current_dist.ingot / 9) ) end - if diff.nuggets > 0 then - diff.nuggets = math.min( - diff.nuggets - (diff.nuggets % NUGGET_RATIO), - current_dist.ingots * 9 + if diff.nugget > 0 then + diff.nugget = math.min( + diff.nugget - (diff.nugget % NUGGET_RATIO), + current_dist.ingot * 9 ) end - diff.ingots = (-diff.nuggets / 9) + (-diff.blocks * 9) + diff.ingot = (-diff.nugget / 9) + (-diff.block * 9) return diff end @@ -201,8 +201,8 @@ function diff_to_crafts (diff) -- go from one end e.g. nuggets to the other e.g. blocks, removing -- from the diff to create crafts until the diff is empty local crafts = {} - crafts.nuggets = math.floor(diff.nuggets / NUGGET_RATIO) - crafts.blocks = math.floor(diff.blocks / BLOCK_RATIO) + crafts.nugget = math.floor(diff.nugget / NUGGET_RATIO) + crafts.block = math.floor(diff.block / BLOCK_RATIO) return crafts end From 76787d4283d5639eff2e6d14f2d3c8fd16bc3a80 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Sat, 17 Jan 2026 17:05:01 -0500 Subject: [PATCH 22/23] fix: remove syntax errors --- compacting-storage.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 8fdd2dd..1fa12b7 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -56,19 +56,19 @@ local getName = { nugget = function (item_type) return ("%s:%s_nugget"):format( ITEM_TYPES[item_type].nugget, - item_type, + item_type ) end, ingot = function (item_type) return ("%s:%s_ingot"):format( ITEM_TYPES[item_type].ingot, - item_type, + item_type ) end, block = function (item_type) return ("%s:%s_block"):format( ITEM_TYPES[item_type].block, - item_type, + item_type ) end, } @@ -90,10 +90,12 @@ function craft (requester, item_type, conversion_type) count = NUGGET_RATIO address = COMPACTING_ADDR else - count = BLOCK_RATIO end + count = BLOCK_RATIO address = UNPACKING_ADDR end - requester.setRequest({ name, count }) + requester.setAddress(address) + requester.setRequest({ name = name, count = count }) + requester.request() end function craft_multiple (requester, item_type, conversion_type, count) @@ -110,10 +112,10 @@ function execute_crafts (requester, item_type, crafts) local num_crafts = crafts.nugget if num_crafts > 0 then print(("Crafting %s nuggets"):format(item_type)) - craft_multiple(item_type, 4, num_crafts) + craft_multiple(requester, item_type, 4, num_crafts) elseif num_crafts < 0 then print(("Crafting %s ingots"):format(item_type)) - craft_multiple(item_type, 1, -num_crafts) + craft_multiple(requester, item_type, 1, -num_crafts) end num_crafts = crafts.block if num_crafts > 0 then @@ -121,7 +123,7 @@ function execute_crafts (requester, item_type, crafts) craft_multiple(requester, item_type, 2, num_crafts) elseif num_crafts < 0 then print(("Crafting %s ingots"):format(item_type)) - craft_multiple(item_type, 3, -num_crafts) + craft_multiple(requester, item_type, 3, -num_crafts) end end @@ -141,15 +143,13 @@ function sum_items (inv_f) end function dist_to_num (dist) - return dist.nugget + dist.ingot * INGOTS + dist.block * BLOCKS + return dist.nugget + (dist.ingot * INGOTS) + (dist.block * BLOCKS) end function get_dist (item_type, items) - -- TODO change plurals to singulars to match mc local dist = { nugget = 0, ingot = 0, block = 0 } for item, count in pairs(items) do local type, form = item:match":(%l-)_(%l*)" - form = string.format("%ss", form) if type == item_type and dist[form] ~= nil then dist[form] = dist[form] + count end From 7e524f29eb156a14bf9494264c22ae2e540ab2fb Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Sat, 17 Jan 2026 18:53:10 -0500 Subject: [PATCH 23/23] fix: fix requesting logic --- compacting-storage.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compacting-storage.lua b/compacting-storage.lua index 1fa12b7..4dbe0fb 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -235,12 +235,13 @@ while true do diff = filter_clamp(diff, current_dist) local crafts = diff_to_crafts(diff) execute_crafts(craft_requester, item_type, crafts) - elseif num > MAX_NUM then - -- keep requesting until above MAX_NUM - requesting[item_type] = nil else requesting[item_type] = true end + if num > MAX_NUM then + -- keep requesting until above MAX_NUM + requesting[item_type] = false + end if requesting[item_type] then request_more(request_t, item_type) end