Advertisement
Goy288

ChestCountDisplayer

Jun 27th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. --Requires PeripheralsPlusOne.
  2. --Designed to work with a computer with a monitor on top and a diamond chest in front.
  3.  
  4. chest = peripheral.wrap("front")
  5. monitor = peripheral.wrap("top")
  6. x = 1
  7. y = 1
  8.  
  9. while true do
  10.     monitor.clear()
  11.     monitor.setCursorPos(x, y)
  12.     chestList = chest.list()
  13.     chestCount = 0
  14.     for slot, item in pairs(chestList) do
  15.         chestCount = chestCount + item.count
  16.     end
  17.     if chestCount > 9999 then
  18.         fontSize = 0.5
  19.     elseif chestCount > 999 then
  20.         fontSize = 2
  21.     elseif chestCount > 99 then
  22.         fontSize = 2.5
  23.     elseif chestCount > 9 then
  24.         fontSize = 4
  25.     else
  26.         fontSize = 5
  27.     end
  28.     monitor.setTextScale(fontSize)
  29.     monitor.write(string.format("%.0f",chestCount))
  30.     sleep(1)
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement