Advertisement
colhaydutu

chris

Apr 15th, 2024 (edited)
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. local chest = peripheral.wrap("right")
  2. local monitor = peripheral.wrap("top")
  3. local redstoneSide = "back"
  4. local min = 5
  5. local max = 10
  6. local targetItem = "minecraft:cobblestone"
  7. local redstoneState = false
  8.  
  9. while true do
  10. local items = chest.list()
  11. local itemCount = 0
  12. for slot, item in pairs(items) do
  13. if item.name == targetItem then
  14. itemCount = itemCount + item.count
  15. end
  16. end
  17.  
  18. monitor.clear()
  19. monitor.setTextScale(0.9)
  20. monitor.setBackgroundColor(colors.white)
  21. monitor.setCursorPos(1, 1)
  22. monitor.setTextColor(colors.black)
  23. monitor.write(targetItem .. " count: " .. itemCount)
  24. monitor.setCursorPos(1, 3)
  25. monitor.write("STATUS:")
  26. monitor.setCursorPos(1, 5)
  27.  
  28. if itemCount > max then
  29. redstone.setOutput(redstoneSide, true)
  30. monitor.write("Redstone turn on")
  31. redstoneState=true
  32. end
  33.  
  34. if itemCount < min and redstoneState==true then
  35. redstone.setOutput(redstoneSide, false)
  36. monitor.write("Redstone turn off")
  37. redstoneState=false
  38. end
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. monitor.setCursorPos(1, 8)
  46. monitor.write("min: " .. min)
  47. monitor.setCursorPos(8, 8)
  48. monitor.write("max: " .. max)
  49. sleep(0.1)
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement