summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-08-04 14:37:35 +0100
committerubq323 <ubq323@ubq323.website>2022-08-04 14:37:35 +0100
commit83cbd87e2c13f8097e0624df061fc200ff96fcaa (patch)
treea4df29800d3f2bcb9bfc2fc87bce14eda35fea56
parent48b51b501e013b11145c3a1eb28c58ec6c0d49b1 (diff)
storage
-rw-r--r--storage.lua17
-rw-r--r--storage_old.lua54
2 files changed, 71 insertions, 0 deletions
diff --git a/storage.lua b/storage.lua
new file mode 100644
index 0000000..5128acd
--- /dev/null
+++ b/storage.lua
@@ -0,0 +1,17 @@
+local M = peripheral.find"monitor"
+
+local sides = {}
+for _,s in ipairs(redstone.getSides()) do sides[s] = true end
+
+local chest_types = {
+ "minecraft:ironchest_diamond",
+ "minecraft:ironchest_iron",
+}
+
+local chests = {}
+for _,ty in ipairs(chest_types) do
+ -- don't want sides, only ones over a network
+ local tc = { peripheral.find(ty,function(n,p) return not sides[n] end) }
+ for _,c in ipairs(tc) do chests[c] = true end
+end
+return chests
diff --git a/storage_old.lua b/storage_old.lua
new file mode 100644
index 0000000..1775122
--- /dev/null
+++ b/storage_old.lua
@@ -0,0 +1,54 @@
+local names = {
+["minecraft:ironchest_diamond_10237"] = "junk2",
+["minecraft:ironchest_diamond_10239"] = "junk1",
+["minecraft:ironchest_iron_2754"] = "computers",
+}
+print("Searching...")
+
+local function search_for(term)
+ local out = {}
+ for phname,phlabel in pairs(names) do
+ local ph = peripheral.wrap(phname)
+ local maxslots = ph.size()
+ for slx = 1,maxslots do
+ local it = ph.getItemMeta(slx)
+ if it then
+ for _,name in ipairs{it.displayName,it.rawName,it.name} do
+ if name and name:lower():find(term) then
+ table.insert(out,{
+ it=it,
+ phname=phname,
+ ph=ph,
+ phlabel=phlabel,
+ slot=slx
+ })
+ --print(it.displayName .. ":" .. it.count .. " in " .. phlabel .. " slot " .. slx)
+ break
+ end
+ end
+ end
+ end
+ end
+ return out
+end
+
+function niceslot(slot)
+ -- row, column
+ return math.floor(slot/9)+1, slot%9
+end
+
+
+rows = {}
+for i,res in ipairs(search_for(arg[1])) do
+ local row,col = niceslot(res.slot)
+
+
+ rows[i] = { res.it.displayName,
+ "x" .. res.it.count,
+ tostring(res.phlabel),
+ row..","..col.." ("..res.slot..")", }
+end
+textutils.pagedTabulate(colors.red, {"name","count","chest","slot"},
+ colors.green, table.unpack(rows))
+
+ \ No newline at end of file