colhaydutu

steampunk chest info screen

Apr 15th, 2024 (edited)
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. local chest = peripheral.wrap("left")
  2. local monitor = peripheral.wrap("top")
  3.  
  4. while true do
  5. local totalSlots = chest.size() -- Toplam slot sayısı
  6. local items = chest.list()
  7. local filledSlots = 0
  8.  
  9. -- Her bir öğeyi işle
  10. for _, item in ipairs(items) do
  11. if item.count == 64 then -- Eğer öğenin tüm yuvaları dolu ise
  12. filledSlots = filledSlots + 1
  13. else
  14. -- Eğer öğenin yuvalarının bir kısmı dolu ise, dolu slot sayısını yuva sayısına ekle
  15. filledSlots = filledSlots + math.ceil(item.count / 64)
  16. end
  17. end
  18.  
  19. local emptySlots = totalSlots - filledSlots -- Boş slot sayısı hesaplama
  20.  
  21. monitor.clear()
  22. monitor.setTextScale(1.1)
  23. monitor.setBackgroundColor(colors.white)
  24. monitor.setCursorPos(1, 1)
  25. monitor.setTextColor(colors.black)
  26. monitor.write("Free slots: " .. emptySlots)
  27. monitor.setCursorPos(1, 2)
  28. monitor.write("Total slots: " .. totalSlots)
  29. sleep(0.1)
  30. end
  31.  
Add Comment
Please, Sign In to add comment