Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitor = peripheral.find("monitor")
- width, height = monitor.getSize()
- function getStorageStatistics()
- local chest = peripheral.find("functionalstorage:storage_controller")
- local capacity = 0
- local size = 0
- for slot, item in pairs(chest.list()) do
- size = size + item.count
- capacity = capacity + chest.getItemLimit(slot)
- end
- return capacity, size
- end
- function drawStatusBar(x, y, width, height, itemsPercent)
- paintutils.drawBox(x, y, width, y + 3, colors.white)
- paintutils.drawFilledBox(x + 1, y + 1, (width / 100) * itemsPercent, y + 2, colors.red)
- monitor.setBackgroundColor(colors.black)
- end
- function main()
- term.redirect(monitor)
- monitor.setTextScale(1)
- while 1 do
- monitor.setBackgroundColor(colors.black)
- local capacity, size = getStorageStatistics()
- local itemsPercent = size * 100 / capacity;
- monitor.setCursorPos(1, 1)
- monitor.write(("Storage is %d%% full [%d | %d items]"):format(itemsPercent, size, capacity))
- drawStatusBar(1, 2, width, height, itemsPercent)
- end
- end
- monitor.clear();
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement