Advertisement
RicDo

Beventory-CC-Tweaked

Jul 4th, 2025
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | Software | 0 0
  1. if arg[1] == nil then
  2.     print("NO ARGUMENTS")
  3.     return
  4. end
  5.  
  6. local target = peripheral.wrap("minecraft:chest_1")
  7. local i1, i2, i3, i4, i5, i6, i7, i8 = peripheral.find("minecraft:barrel")
  8. local alli = {i1,i2,i3,i4,i5,i6,i7,i8}
  9. local s1, s2 = peripheral.find("speaker")
  10. local alls = {s1,s2}
  11.  
  12. function makeSound(speaker, sound)
  13.     for i,sp in ipairs(speaker) do
  14.         sp.playSound(sound)
  15.     end
  16. end
  17.  
  18. function readItems(inventory)
  19.     if inventory.list() ~= nil then
  20.         for i,item in pairs(inventory.list()) do
  21.             print(item.name, " - ", item.count)
  22.         end
  23.     end
  24. end
  25.  
  26. function findItems(inventory, target, targetItem)
  27.     local sum = 0
  28.     for i, item in pairs(inventory.list()) do
  29.         if item.name == targetItem then
  30.             inventory.pushItems(peripheral.getName(target), i)
  31.             sum = sum + 1
  32.         end
  33.     end
  34.     if sum <= 0 then
  35.         makeSound(alls, "minecraft:entity.villager.no")
  36.         print(targetItem, " was not found in ", peripheral.getName(inventory))
  37.     else
  38.         makeSound(alls, "minecraft:entity.villager.yes")
  39.         print("Success")    
  40.     end
  41. end
  42.  
  43. --for i, chest in pairs(all) do
  44. --    readItems(chest)    
  45. --end
  46.  
  47. for i, chest in pairs(alli) do
  48.     findItems(chest, target, arg[1])
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement