From 9c2731543160949cf63bb0f922dd30d222430e69 Mon Sep 17 00:00:00 2001 From: Bradley <90872694+Bituvo@users.noreply.github.com> Date: Tue, 12 Aug 2025 14:12:59 -0400 Subject: [PATCH 01/12] Add controller "get" command --- lua/controller.lua | 51 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/lua/controller.lua b/lua/controller.lua index 2fda667..4787e61 100644 --- a/lua/controller.lua +++ b/lua/controller.lua @@ -374,12 +374,57 @@ end local function controller_on_digiline_receive(pos, _, channel, msg) local meta = core.get_meta(pos) - if channel ~= meta:get_string("digilineChannel") then + if not msg or channel ~= meta:get_string("digilineChannel") then return end - if msg and type(msg) ~= "string" and type(msg) ~= "table" then - return -- Protect against ItemStack(...) errors + if type(msg) == "string" then + if msg == "get" then + local found_drawers = {} + local index = index_drawers(pos) + + -- Add each drawer in the network separately + local drawer_positions = {} + for _, drawer in pairs(index) do + local position = drawer.drawer_pos + local key = vector.to_string(position) + if not drawer_positions[key] then + drawer_positions[key] = position + end + end + + for _, position in pairs(drawer_positions) do + local node = core.get_node(position) + local drawer_meta = core.get_meta(position) + local node_def = core.registered_nodes[node.name] + local drawer_type = node_def.groups.drawer + + -- Record information of each slot + local slots = {} + for i = 1, drawer_type do + -- 1x1 drawers don't have numbers in the meta fields + if drawer_type == 1 then i = "" end + local slot_name = drawer_meta:get_string("name" .. i) + local slot_count = drawer_meta:get_int("count" .. i) + local slot_max = drawer_meta:get_int("max_count" .. i) + + table.insert(slots, { + name = slot_name, + count = slot_count, + max = slot_max + }) + end + + table.insert(found_drawers, {position=position, slots=slots}) + end + + digiline:receptor_send(pos, digilines.rules.default, channel, found_drawers) + return + end + + elseif type(msg) ~= "table" then + -- Protect against ItemStack(...) errors + return end local item = ItemStack(msg) From 87d3be4cac05e3d9c2ce553308270d7ac5b5de5e Mon Sep 17 00:00:00 2001 From: Bradley <90872694+Bituvo@users.noreply.github.com> Date: Tue, 12 Aug 2025 16:25:35 -0400 Subject: [PATCH 02/12] Move to separate function, add pagination --- init.lua | 1 + lua/controller.lua | 121 +++++++++++++++++++++++++++++---------------- 2 files changed, 80 insertions(+), 42 deletions(-) diff --git a/init.lua b/init.lua index 020a40e..26fecbb 100755 --- a/init.lua +++ b/init.lua @@ -52,6 +52,7 @@ drawers.enable_1x2 = not core.settings:get_bool("drawers_disable_1x2") drawers.enable_2x2 = not core.settings:get_bool("drawers_disable_2x2") drawers.CONTROLLER_RANGE = 14 +drawers.CONTROLLER_MAX_MATCHES = 50 -- -- GUI diff --git a/lua/controller.lua b/lua/controller.lua index 4787e61..649ada3 100644 --- a/lua/controller.lua +++ b/lua/controller.lua @@ -297,6 +297,79 @@ local function controller_insert_to_drawers(pos, stack) return stack end +--[[ + Returns an array of drawers in the drawer network with their positions and slot + data. Slot data includes stored item, item count, and max count. + + Results can be paginated by specifying an `offset` and a `max_count`. +]] +local function controller_get_network_info(pos, offset, max_count) + local found_drawers = {} + local index = index_drawers(pos) + + -- Add each drawer in the network separately + -- Sort them by their positions to keep order for pagination + local drawer_positions = {} + local drawer_count = 0 + local keys = {} + for _, drawer in pairs(index) do + local position = drawer.drawer_pos + local key = vector.to_string(position) + + if not drawer_positions[key] then + drawer_positions[key] = position + table.insert(keys, key) + drawer_count = drawer_count + 1 + end + end + table.sort(keys) + + for _, key in ipairs(keys) do + local position = drawer_positions[key] + local node = core.get_node(position) + local drawer_meta = core.get_meta(position) + local node_def = core.registered_nodes[node.name] + local drawer_type = node_def.groups.drawer + + -- Record information of each slot + local slots = {} + for i = 1, drawer_type do + -- 1x1 drawers don't have numbers in the meta fields + if drawer_type == 1 then i = "" end + local slot_name = drawer_meta:get_string("name" .. i) + local slot_count = drawer_meta:get_int("count" .. i) + local slot_max = drawer_meta:get_int("max_count" .. i) + + table.insert(slots, { + name = slot_name, + count = slot_count, + max = slot_max + }) + end + + table.insert(found_drawers, {position=position, slots=slots}) + end + + -- Offset must be an integer and >= 1 + offset = (type(offset) == "number") and + math.max(1, math.floor(offset)) or 1 + -- Max count must be an integer, >= 1, and <= MAX_MATCHES + max_count = (type(max_count) == "number") and + math.min(math.max(1, math.floor(max_count)), + drawers.CONTROLLER_MAX_MATCHES) or drawers.CONTROLLER_MAX_MATCHES + + -- Paginate if results exceed our limits + if (drawer_count > max_count) or (offset > 1) then + local temp = {} + for i = offset, offset + max_count - 1 do + table.insert(temp, found_drawers[i]) + end + found_drawers = temp + end + + return found_drawers +end + local function controller_can_dig(pos, player) local meta = core.get_meta(pos); local inv = meta:get_inventory() @@ -378,51 +451,15 @@ local function controller_on_digiline_receive(pos, _, channel, msg) return end - if type(msg) == "string" then - if msg == "get" then - local found_drawers = {} - local index = index_drawers(pos) - - -- Add each drawer in the network separately - local drawer_positions = {} - for _, drawer in pairs(index) do - local position = drawer.drawer_pos - local key = vector.to_string(position) - if not drawer_positions[key] then - drawer_positions[key] = position - end - end - - for _, position in pairs(drawer_positions) do - local node = core.get_node(position) - local drawer_meta = core.get_meta(position) - local node_def = core.registered_nodes[node.name] - local drawer_type = node_def.groups.drawer - - -- Record information of each slot - local slots = {} - for i = 1, drawer_type do - -- 1x1 drawers don't have numbers in the meta fields - if drawer_type == 1 then i = "" end - local slot_name = drawer_meta:get_string("name" .. i) - local slot_count = drawer_meta:get_int("count" .. i) - local slot_max = drawer_meta:get_int("max_count" .. i) - - table.insert(slots, { - name = slot_name, - count = slot_count, - max = slot_max - }) - end - - table.insert(found_drawers, {position=position, slots=slots}) - end - - digiline:receptor_send(pos, digilines.rules.default, channel, found_drawers) + if type(msg) == "table" then + if msg.command == "get" then + digiline:receptor_send(pos, digilines.rules.default, channel, + controller_get_network_info(pos, msg.offset, msg.max_count) + ) return end - elseif type(msg) ~= "table" then + elseif type(msg) ~= "string" then -- Protect against ItemStack(...) errors return end From 34cd8d7ba7614e43caa90ce57d14eed84497ab85 Mon Sep 17 00:00:00 2001 From: Bradley <90872694+Bituvo@users.noreply.github.com> Date: Thu, 21 Aug 2025 13:47:53 -0400 Subject: [PATCH 03/12] Don't overwrite loop variable --- lua/controller.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/controller.lua b/lua/controller.lua index 649ada3..cdcd5fe 100644 --- a/lua/controller.lua +++ b/lua/controller.lua @@ -335,10 +335,10 @@ local function controller_get_network_info(pos, offset, max_count) local slots = {} for i = 1, drawer_type do -- 1x1 drawers don't have numbers in the meta fields - if drawer_type == 1 then i = "" end - local slot_name = drawer_meta:get_string("name" .. i) - local slot_count = drawer_meta:get_int("count" .. i) - local slot_max = drawer_meta:get_int("max_count" .. i) + local slot_id = (drawer_type == 1 and "") or i + local slot_name = drawer_meta:get_string("name" .. slot_id) + local slot_count = drawer_meta:get_int("count" .. slot_id) + local slot_max = drawer_meta:get_int("max_count" .. slot_id) table.insert(slots, { name = slot_name, From a624bd581426a44a8f8768a79dd77a359e849fb5 Mon Sep 17 00:00:00 2001 From: Bradley <90872694+Bituvo@users.noreply.github.com> Date: Thu, 21 Aug 2025 13:48:59 -0400 Subject: [PATCH 04/12] Add `digiline` global to .luacheckrc --- .luacheckrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.luacheckrc b/.luacheckrc index 93f08bc..7dba529 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -24,6 +24,7 @@ read_globals = { "pipeworks", "screwdriver", "digilines", + "digiline", "mesecon", "techage" } From 016e2c1cb7385c2a6158ed22a836e4752427542f Mon Sep 17 00:00:00 2001 From: Bradley <90872694+Bituvo@users.noreply.github.com> Date: Sat, 23 Aug 2025 20:05:29 -0400 Subject: [PATCH 05/12] Shorten `offset` and `max_count` calculations --- lua/controller.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lua/controller.lua b/lua/controller.lua index cdcd5fe..1975fb0 100644 --- a/lua/controller.lua +++ b/lua/controller.lua @@ -351,12 +351,10 @@ local function controller_get_network_info(pos, offset, max_count) end -- Offset must be an integer and >= 1 - offset = (type(offset) == "number") and - math.max(1, math.floor(offset)) or 1 + offset = math.max(1, math.floor(tonumber(offset) or 1)) -- Max count must be an integer, >= 1, and <= MAX_MATCHES - max_count = (type(max_count) == "number") and - math.min(math.max(1, math.floor(max_count)), - drawers.CONTROLLER_MAX_MATCHES) or drawers.CONTROLLER_MAX_MATCHES + max_count = math.floor(tonumber(max_count) or drawers.CONTROLLER_MAX_MATCHES) + max_count = math.min(math.max(1, max_count), drawers.CONTROLLER_MAX_MATCHES) -- Paginate if results exceed our limits if (drawer_count > max_count) or (offset > 1) then From 8614a426d027369bda07cf25814c3d5773097eb2 Mon Sep 17 00:00:00 2001 From: Bradley <90872694+Bituvo@users.noreply.github.com> Date: Sat, 23 Aug 2025 20:21:02 -0400 Subject: [PATCH 06/12] Optimize pagination --- lua/controller.lua | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/lua/controller.lua b/lua/controller.lua index 1975fb0..ee56cbe 100644 --- a/lua/controller.lua +++ b/lua/controller.lua @@ -310,21 +310,28 @@ local function controller_get_network_info(pos, offset, max_count) -- Add each drawer in the network separately -- Sort them by their positions to keep order for pagination local drawer_positions = {} - local drawer_count = 0 local keys = {} for _, drawer in pairs(index) do local position = drawer.drawer_pos - local key = vector.to_string(position) + local key = core.hash_node_position(position) if not drawer_positions[key] then drawer_positions[key] = position table.insert(keys, key) - drawer_count = drawer_count + 1 end end table.sort(keys) - for _, key in ipairs(keys) do + -- Offset must be an integer and >= 1 + offset = math.max(1, math.floor(tonumber(offset) or 1)) + -- Max count must be an integer, >= 1, and <= MAX_MATCHES + max_count = math.floor(tonumber(max_count) or drawers.CONTROLLER_MAX_MATCHES) + max_count = math.min(math.max(1, max_count), drawers.CONTROLLER_MAX_MATCHES) + + for i = offset, offset + max_count - 1 do + local key = keys[i] + if not key then break end + local position = drawer_positions[key] local node = core.get_node(position) local drawer_meta = core.get_meta(position) @@ -333,9 +340,9 @@ local function controller_get_network_info(pos, offset, max_count) -- Record information of each slot local slots = {} - for i = 1, drawer_type do + for slot = 1, drawer_type do -- 1x1 drawers don't have numbers in the meta fields - local slot_id = (drawer_type == 1 and "") or i + local slot_id = (drawer_type == 1 and "") or slot local slot_name = drawer_meta:get_string("name" .. slot_id) local slot_count = drawer_meta:get_int("count" .. slot_id) local slot_max = drawer_meta:get_int("max_count" .. slot_id) @@ -350,21 +357,6 @@ local function controller_get_network_info(pos, offset, max_count) table.insert(found_drawers, {position=position, slots=slots}) end - -- Offset must be an integer and >= 1 - offset = math.max(1, math.floor(tonumber(offset) or 1)) - -- Max count must be an integer, >= 1, and <= MAX_MATCHES - max_count = math.floor(tonumber(max_count) or drawers.CONTROLLER_MAX_MATCHES) - max_count = math.min(math.max(1, max_count), drawers.CONTROLLER_MAX_MATCHES) - - -- Paginate if results exceed our limits - if (drawer_count > max_count) or (offset > 1) then - local temp = {} - for i = offset, offset + max_count - 1 do - table.insert(temp, found_drawers[i]) - end - found_drawers = temp - end - return found_drawers end From 51e2aa1f9f0e4949f3391698ee0475d23b998997 Mon Sep 17 00:00:00 2001 From: Bradley <90872694+Bituvo@users.noreply.github.com> Date: Sat, 23 Aug 2025 20:28:52 -0400 Subject: [PATCH 07/12] Use `find_connected_drawers` instead of `index_drawers` --- lua/controller.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lua/controller.lua b/lua/controller.lua index ee56cbe..db145db 100644 --- a/lua/controller.lua +++ b/lua/controller.lua @@ -305,16 +305,14 @@ end ]] local function controller_get_network_info(pos, offset, max_count) local found_drawers = {} - local index = index_drawers(pos) + local connected_drawers = find_connected_drawers(pos) -- Add each drawer in the network separately -- Sort them by their positions to keep order for pagination local drawer_positions = {} local keys = {} - for _, drawer in pairs(index) do - local position = drawer.drawer_pos + for _, position in pairs(connected_drawers) do local key = core.hash_node_position(position) - if not drawer_positions[key] then drawer_positions[key] = position table.insert(keys, key) From 5b4be0f7869f1108c7d450598dc01fea0c2e3399 Mon Sep 17 00:00:00 2001 From: Bradley <90872694+Bituvo@users.noreply.github.com> Date: Sat, 23 Aug 2025 20:36:54 -0400 Subject: [PATCH 08/12] Optimize drawer iteration --- lua/controller.lua | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lua/controller.lua b/lua/controller.lua index db145db..d783280 100644 --- a/lua/controller.lua +++ b/lua/controller.lua @@ -307,18 +307,10 @@ local function controller_get_network_info(pos, offset, max_count) local found_drawers = {} local connected_drawers = find_connected_drawers(pos) - -- Add each drawer in the network separately - -- Sort them by their positions to keep order for pagination - local drawer_positions = {} - local keys = {} - for _, position in pairs(connected_drawers) do - local key = core.hash_node_position(position) - if not drawer_positions[key] then - drawer_positions[key] = position - table.insert(keys, key) - end - end - table.sort(keys) + -- Sort drawers by their positions to keep order for pagination + table.sort(connected_drawers, function(a, b) + return core.hash_node_position(a) < core.hash_node_position(b) + end) -- Offset must be an integer and >= 1 offset = math.max(1, math.floor(tonumber(offset) or 1)) @@ -327,10 +319,9 @@ local function controller_get_network_info(pos, offset, max_count) max_count = math.min(math.max(1, max_count), drawers.CONTROLLER_MAX_MATCHES) for i = offset, offset + max_count - 1 do - local key = keys[i] - if not key then break end + local position = connected_drawers[i] + if not position then break end - local position = drawer_positions[key] local node = core.get_node(position) local drawer_meta = core.get_meta(position) local node_def = core.registered_nodes[node.name] From 3da176a988254d04e90577c0918bac272301e627 Mon Sep 17 00:00:00 2001 From: Bradley <90872694+Bituvo@users.noreply.github.com> Date: Sat, 23 Aug 2025 20:46:33 -0400 Subject: [PATCH 09/12] Document digilines API --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 0a50cc0..f1d2281 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,26 @@ Do you have too many cobblestones for one drawer? No problem, just add some drawer upgrades to your drawer! They are available in different sizes and are crafted by steel, gold, obsidian, diamonds or mithril. +## Digilines +The drawer controller is digilines-compatible. To request an item from the +surrounding drawers, send an itemstring to its channel: +* `"default:dirt 15"` +* `"default:cobble"` + +The items will be sent out the back of the drawer controller. + +To request the contents of a drawer network, send a table with the following +format: + +1. `command` (string) - `"get"` +2. `offset` (integer) - Used to paginate the results if the amount of drawers in + the network exceeds `drawers.CONTROLLER_MAX_COUNT`. Defaults to 1. +3. `max_count` (integer) - Must be between 1 and `CONTROLLER_MAX_COUNT`. + Defaults to `CONTROLLER_MAX_COUNT`. Maximum amount of drawers to return. + +A table will be sent back on the same channel containing each drawer's position +and the contents of each of their slots. + ## Notes This mod requires Minetest 5.0 or later. The `default` mod from MTG or the MineClone 2 mods are only optional dependencies for crafting recipes. From 79d60852bbc05edaf206054db09f86db9594c0d8 Mon Sep 17 00:00:00 2001 From: Bradley <90872694+Bituvo@users.noreply.github.com> Date: Fri, 29 Aug 2025 16:52:13 -0400 Subject: [PATCH 10/12] Move `CONTROLLER_MAX_MATCHES` to settings --- init.lua | 1 - lua/controller.lua | 8 +++++--- settingtypes.txt | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 26fecbb..020a40e 100755 --- a/init.lua +++ b/init.lua @@ -52,7 +52,6 @@ drawers.enable_1x2 = not core.settings:get_bool("drawers_disable_1x2") drawers.enable_2x2 = not core.settings:get_bool("drawers_disable_2x2") drawers.CONTROLLER_RANGE = 14 -drawers.CONTROLLER_MAX_MATCHES = 50 -- -- GUI diff --git a/lua/controller.lua b/lua/controller.lua index d783280..d786a01 100644 --- a/lua/controller.lua +++ b/lua/controller.lua @@ -46,6 +46,8 @@ local pipeworks_loaded = core.get_modpath("pipeworks") and pipeworks local digilines_loaded = core.get_modpath("digilines") and digilines local techage_loaded = core.get_modpath("techage") and techage +local max_matches = tonumber(core.settings:get("drawers.controller_max_matches")) or 50 + local function controller_formspec(pos) local formspec = "size[9,8.5]".. @@ -314,9 +316,9 @@ local function controller_get_network_info(pos, offset, max_count) -- Offset must be an integer and >= 1 offset = math.max(1, math.floor(tonumber(offset) or 1)) - -- Max count must be an integer, >= 1, and <= MAX_MATCHES - max_count = math.floor(tonumber(max_count) or drawers.CONTROLLER_MAX_MATCHES) - max_count = math.min(math.max(1, max_count), drawers.CONTROLLER_MAX_MATCHES) + -- Max count must be an integer, >= 1, and <= max_matches + max_count = math.floor(tonumber(max_count) or max_matches) + max_count = math.min(math.max(1, max_count), max_matches) for i = offset, offset + max_count - 1 do local position = connected_drawers[i] diff --git a/settingtypes.txt b/settingtypes.txt index e69de29..84c1f07 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -0,0 +1 @@ +drawers.controller_max_matches (Maximum controller request matches) int 50 From ab95897b2c4eb833742e9fc9ff84c61afb2e6e30 Mon Sep 17 00:00:00 2001 From: Bradley <90872694+Bituvo@users.noreply.github.com> Date: Sun, 31 Aug 2025 16:50:12 -0400 Subject: [PATCH 11/12] Use `VoxelManip` and DFS --- .luacheckrc | 1 + init.lua | 7 ++++- lua/controller.lua | 72 ++++++++++++++++++++++++++++++++++------------ 3 files changed, 60 insertions(+), 20 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 7dba529..eb3ba91 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -14,6 +14,7 @@ read_globals = { -- Minetest "vector", "ItemStack", "dump", "VoxelArea", + "VoxelManip", -- deps "minetest", diff --git a/init.lua b/init.lua index 020a40e..b632784 100755 --- a/init.lua +++ b/init.lua @@ -78,7 +78,6 @@ end dofile(MP .. "/lua/helpers.lua") dofile(MP .. "/lua/visual.lua") dofile(MP .. "/lua/api.lua") -dofile(MP .. "/lua/controller.lua") -- @@ -373,6 +372,12 @@ core.register_craft({ } }) +-- +-- Register drawer controller +-- + +dofile(MP .. "/lua/controller.lua") + -- -- Register drawer upgrade template -- diff --git a/lua/controller.lua b/lua/controller.lua index d786a01..37321f2 100644 --- a/lua/controller.lua +++ b/lua/controller.lua @@ -48,6 +48,27 @@ local techage_loaded = core.get_modpath("techage") and techage local max_matches = tonumber(core.settings:get("drawers.controller_max_matches")) or 50 +-- Cache content IDS of all registered drawer items +local controller_content_id +local drawer_content_ids = {} +for name, _ in pairs(core.registered_items) do + if core.get_item_group(name, "drawer") > 0 or core.get_item_group(name, "drawer_connector") > 0 then + drawer_content_ids[core.get_content_id(name)] = true + end +end + +-- Cache position offsets to find connected drawers +local offsets = {} +for dx = -1, 1 do + for dy = -1, 1 do + for dz = -1, 1 do + if dx ~= 0 or dy ~= 0 or dz ~= 0 then + table.insert(offsets, vector.new(dx, dy, dz)) + end + end + end +end + local function controller_formspec(pos) local formspec = "size[9,8.5]".. @@ -173,28 +194,40 @@ local function add_drawer_to_inventory(controllerInventory, pos) end end -local function find_connected_drawers(controller_pos, pos, foundPositions) - foundPositions = foundPositions or {} - pos = pos or controller_pos - - local newPositions = core.find_nodes_in_area( - {x = pos.x - 1, y = pos.y - 1, z = pos.z - 1}, - {x = pos.x + 1, y = pos.y + 1, z = pos.z + 1}, - {"group:drawer", "group:drawer_connector"} - ) - - for _,p in ipairs(newPositions) do - -- check that this node hasn't been scanned yet - if not compare_pos(pos, p) and not contains_pos(foundPositions, p) - and pos_in_range(controller_pos, pos) then - -- add new position - table.insert(foundPositions, p) - -- search for other drawers from the new pos - find_connected_drawers(controller_pos, p, foundPositions) +local function find_connected_drawers(controller_pos) + local minp = vector.subtract(controller_pos, drawers.CONTROLLER_RANGE) + local maxp = vector.add(controller_pos, drawers.CONTROLLER_RANGE) + + local vm = VoxelManip() + local emin, emax = vm:read_from_map(minp, maxp) + local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax}) + local data = vm:get_data() + + local found = {} + local visited = {} + + local function dfs(pos) + local index = area:indexp(pos) + if visited[index] then return end + visited[index] = true + + local content_id = data[index] + if drawer_content_ids[content_id] then + table.insert(found, pos) + elseif content_id ~= controller_content_id then + return + end + + for _, offset in ipairs(offsets) do + local neighbor = vector.add(pos, offset) + if pos_in_range(controller_pos, neighbor) then + dfs(neighbor) + end end end - return foundPositions + dfs(controller_pos) + return found end local function index_drawers(pos) @@ -564,6 +597,7 @@ local function register_controller() end core.register_node("drawers:controller", def) + controller_content_id = core.get_content_id("drawers:controller") if techage_loaded then techage.register_node({"drawers:controller"}, { From 18aa38adb850bd5d5ce8c2d7ea98b3dd04ed8611 Mon Sep 17 00:00:00 2001 From: Bradley <90872694+Bituvo@users.noreply.github.com> Date: Sun, 31 Aug 2025 17:08:45 -0400 Subject: [PATCH 12/12] Make trim work --- lua/controller.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/controller.lua b/lua/controller.lua index 37321f2..9441422 100644 --- a/lua/controller.lua +++ b/lua/controller.lua @@ -50,6 +50,7 @@ local max_matches = tonumber(core.settings:get("drawers.controller_max_matches") -- Cache content IDS of all registered drawer items local controller_content_id +local trim_content_id = core.get_content_id("drawers:trim") local drawer_content_ids = {} for name, _ in pairs(core.registered_items) do if core.get_item_group(name, "drawer") > 0 or core.get_item_group(name, "drawer_connector") > 0 then @@ -213,7 +214,9 @@ local function find_connected_drawers(controller_pos) local content_id = data[index] if drawer_content_ids[content_id] then - table.insert(found, pos) + if content_id ~= trim_content_id then + table.insert(found, pos) + end elseif content_id ~= controller_content_id then return end