diff options
author | ubq323 <ubq323@ubq323.website> | 2022-08-04 16:12:08 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2022-08-04 16:12:08 +0100 |
commit | 52ddc81f472551413584d17433e7ddfe7373f068 (patch) | |
tree | 24439580866c0831947f18894ca5864227d8e152 | |
parent | 0f336519510adcc4fe10f143377dda1e3349acae (diff) |
storage
-rw-r--r-- | storage.lua | 14 |
1 files 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 |