Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local chestType = "TYPE HERE"
- local enderChest = peripheral.find(chestType)
- if enderChest == nill then
- error("Chest "..chestType.." non trouvé, verifier configuration (l1)")
- else
- print(chestType.."trouve")
- end
- monitor = peripheral.find("monitor") or error("Pas de moniteur")
- monitor.clear()
- monitor.setBackgroundColor(colors.black)
- size = monitor.getSize()
- function count(chest)
- local item
- --parcours des items du chest
- ind = 4
- for i=1, #chest.list() do
- item = chest.getItemDetail(i)
- monitor.setCursorPos(1,ind)
- itemName = item.displayName
- itemCount = item.count
- itemMax = item.maxCount
- monitor.write(itemName.." - "..itemCount.."/"..itemMax)
- ind=ind+1
- monitor.setCursorPos(1,ind)
- ind=ind+1
- percent = math.floor((itemCount/itemMax)*100).."%"
- percentLength = string.len(percent)
- --size defined on top, width of the monitor
- ratio = size/itemMax
- itemCount = itemCount*ratio
- itemMax = itemMax*ratio
- for j=1, percentLength, 1 do
- monitor.blit(string.sub(percent, j,j), "0","d")
- end
- for j=percentLength,itemCount,1 do
- monitor.blit (" ","d","d")
- end
- for j=itemCount,itemMax-1,1 do
- monitor.blit(" ","e","e")
- end
- end
- end
- function stored(chest)
- local cpt = 0
- local list = {}
- list = chest.list()
- for i=1, chest.size(), 1 do
- if list[i] ~= nil then
- cpt = cpt+list[i].count
- end
- end
- return cpt
- end
- --refresh toutes les 5 secondes
- while true do
- redstone.setAnalogOutput("right", 0)
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write("Chest usage percent")
- monitor.setCursorPos(1,2)
- local slots =(enderChest.size()*64)
- local used = (math.floor(stored(enderChest)))
- local percent = math.floor((used/slots)*100).."%"
- local ratio = size/slots
- slots = slots*ratio
- used = used*ratio
- for i=1,string.len(percent) ,1 do
- monitor.blit( string.sub(percent,i,i),"0","d")
- end
- for i=string.len(percent), used,1 do
- monitor.blit(" ","d","d")
- end
- for i=used, slots, 1 do
- monitor.blit(" ","9","9")
- end
- monitor.setCursorPos(1,3)
- monitor.write("Detail")
- count(enderChest)
- print(stored(enderChest))
- print(slots*32)
- check = stored(enderChest)
- while check > slots*32 do
- print(check.." > "..slots*32)
- check = stored(enderChest)
- redstone.setOutput("right", true)
- end
- os.sleep(1)
- end
Add Comment
Please, Sign In to add comment