wv1106

startup.lua

Sep 3rd, 2022
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. local monitor = peripheral.find("monitor")
  2. local chest = {peripheral.find("minecraft:chest")}
  3. local trash = {peripheral.find("appliedenergistics2:condenser")}
  4.  
  5.  
  6.  
  7. term.redirect(monitor)
  8. term.setBackgroundColor(colors.black)
  9. term.clear()
  10. local enderPearlImage = paintutils.loadImage("graphics/enderPearl.nfp")
  11. paintutils.drawImage(enderPearlImage, 11, 2)
  12.  
  13. function drawProgressBar(value, max)
  14.     paintutils.drawLine(1, 11, 29, 11, colors.black)
  15.     paintutils.drawLine(5, 10, 25, 10, colors.red)
  16.     local pixel = math.ceil((20/max)*value)+5
  17.     paintutils.drawLine(5, 10, pixel, 10, colors.green)
  18.  
  19.     local quantityString = value.." / "..max
  20.     local xPos = math.ceil(29/2-#quantityString/2)
  21.     term.setBackgroundColor(colors.black)
  22.     term.setCursorPos(xPos, 11)
  23.     term.write(quantityString)
  24. end
  25.  
  26. function getChestFilledSlots(chest)
  27.     local amount = 0
  28.     for i, chest in pairs(chest.list()) do
  29.         amount=amount+1
  30.     end
  31.     return amount
  32. end
  33.  
  34. local storageSizes = {}
  35. local totalSlots = 0
  36. for i, chest in pairs(chest) do
  37.     table.insert(storageSizes, chest.size())
  38.     totalSlots=totalSlots+ chest.size()
  39. end
  40.  
  41. local chestFilledSlots = {}
  42. while true do
  43.     for i, chest in pairs(chest) do
  44.         chestFilledSlots[i] = getChestFilledSlots(chest)
  45.     end
  46.  
  47.     local totalFilledSlots = 0
  48.     for i, amount in pairs(chestFilledSlots) do
  49.         totalFilledSlots=totalFilledSlots+amount
  50.     end
  51.  
  52.     for i=1,#chestFilledSlots do
  53.         if chestFilledSlots[i]==storageSizes[i] then
  54.             chest[i].pushItems(peripheral.getName(trash[1]), storageSizes[i])
  55.         end
  56.     end
  57.  
  58.     drawProgressBar(totalFilledSlots*64, totalSlots*64)
  59.     sleep(0.1)
  60. end
Advertisement
Add Comment
Please, Sign In to add comment