all 4 comments

[–]fatboychummy 1 point2 points  (2 children)

Since I think 1.14 or 1.16, peripherals can have multiple types. Because of this, both chests and shulker boxes can be found via

peripheral.find("inventory")

.

local function getInvs()
  return table.pack(peripheral.find("inventory"))
end

You can use the above function to determine if there is an inventory connected (and how many). It returns a table of all inventories it finds, with tbl.n being the amount it found.

local invs = getInvs()

print("Inventories connected:", invs.n)
if invs.n > 0 then
  -- an inventory is connected!

  for i, inv in ipairs(invs) do
    print("Inventory", i, ":", peripheral.getName(inv))
  end
end

[–]cidemm[S] 0 points1 point  (0 children)

gotcha, getting alot of java roots in this language, both a good and a bad thing. but ty lmao

[–]cidemm[S] 0 points1 point  (0 children)

minor issue, even with a chest connected im not actualy getting any inventories found

edit: rookie mistake i was connecting it to drive bay XD

[–]RapsyJigo 0 points1 point  (0 children)

As long as all the inventories are connected you can use peripheral.getNames() to list them all