Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local chest = peripheral.wrap("right")
- local monitor = peripheral.wrap("top")
- local redstoneSide = "back"
- local min = 5
- local max = 10
- local targetItem = "minecraft:cobblestone"
- local redstoneState = false
- while true do
- local items = chest.list()
- local itemCount = 0
- for slot, item in pairs(items) do
- if item.name == targetItem then
- itemCount = itemCount + item.count
- end
- end
- monitor.clear()
- monitor.setTextScale(0.9)
- monitor.setBackgroundColor(colors.white)
- monitor.setCursorPos(1, 1)
- monitor.setTextColor(colors.black)
- monitor.write(targetItem .. " count: " .. itemCount)
- monitor.setCursorPos(1, 3)
- monitor.write("STATUS:")
- monitor.setCursorPos(1, 5)
- if itemCount > max then
- redstone.setOutput(redstoneSide, true)
- monitor.write("Redstone turn on")
- redstoneState=true
- end
- if itemCount < min and redstoneState==true then
- redstone.setOutput(redstoneSide, false)
- monitor.write("Redstone turn off")
- redstoneState=false
- end
- monitor.setCursorPos(1, 8)
- monitor.write("min: " .. min)
- monitor.setCursorPos(8, 8)
- monitor.write("max: " .. max)
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement