Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Assuming the container is connected to the left side of the computer
- local container = peripheral.wrap("bottom")
- -- Assuming the item you want to count is "minecraft:diamond"
- local itemToCount = "minecraft:diamondore"
- -- Get the inventory size of the container
- local size = container.size()
- -- Loop through each slot and count the number of items
- local itemCount = 0
- for slot = 1, size do
- local stack = container.getStackInSlot(slot)
- if stack and stack.name == itemToCount then
- itemCount = itemCount + stack.size
- end
- end
- -- Print the total count of the item
- print("Total count of " .. itemToCount .. " in container: " .. itemCount)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement