From 52ddc81f472551413584d17433e7ddfe7373f068 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 4 Aug 2022 16:12:08 +0100 Subject: storage --- storage.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/storage.lua b/storage.lua index f587f56..87b8743 100644 --- a/storage.lua +++ b/storage.lua @@ -1,4 +1,10 @@ -local M = peripheral.find"monitor" +--local M = peripheral.find"monitor" + +local ok,chestnames = pcall(require,"chestnames") +if not ok then chestnames = {} end +chestnames = chestnames or {} +setmetatable(chestnames, {__index=function(t,k) return k end}) + local sides = {} for _,s in ipairs(redstone.getSides()) do sides[s] = true end @@ -28,10 +34,10 @@ end local function search(query) local chests = scan() for chname,chest in pairs(chests) do - for i=1,chest.size do - local it = chest.content[i] + for slot=1,chest.size do + local it = chest.content[slot] if it and it.name:lower():find(query) then - print(it.name,"x"..it.count) + print(it.name,"x"..it.count,chestnames[chname]) end end end -- cgit v1.2.3