Advertisement
Grexxity

fml

May 11th, 2023
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. -- Assuming the container is connected to the left side of the computer
  2. local container = peripheral.wrap("bottom")
  3.  
  4. -- Assuming the item you want to count is "minecraft:diamond"
  5. local itemToCount = "minecraft:diamondore"
  6.  
  7. -- Get the inventory size of the container
  8. local size = container.size()
  9.  
  10. -- Loop through each slot and count the number of items
  11. local itemCount = 0
  12. for slot = 1, size do
  13.   local stack = container.getStackInSlot(slot)
  14.   if stack and stack.name == itemToCount then
  15.     itemCount = itemCount + stack.size
  16.   end
  17. end
  18.  
  19. -- Print the total count of the item
  20. print("Total count of " .. itemToCount .. " in container: " .. itemCount)
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement