Advertisement
Shterman

DissolverManagerV3

Jan 27th, 2023 (edited)
871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. --VAR--
  2. local barrel = peripheral.wrap("top")
  3. local diss = peripheral.wrap("bottom")
  4. local outChest = peripheral.wrap("left")
  5.  
  6. local dissSlots = diss.size()
  7. local slotWithItems = 0
  8. local outputWithItems = 2
  9.  
  10. --FUNCTION--
  11. function CheckForChemInBarrel(barr)
  12.     local i = 0
  13.  
  14.     for slot, item in pairs(barr.list()) do
  15.         i = i + 1
  16.         if item.count >= 1 then
  17.             slotWithItems = slot
  18.             return true
  19.         else
  20.             slotWithItems = 0
  21.             return false
  22.         end
  23.     end
  24. end
  25.  
  26. function PushItems()
  27.     barrel.pushItems(peripheral.getName(diss), slotWithItems, 64, 1)
  28. end
  29.  
  30. function PushItemsToOutput()
  31.     while dissSlots > 1 do
  32.         diss.pushItemsToOutput(peripheral.getName(outChest), dissSlots)
  33.         dissSlots = dissSlots - 1
  34.     end
  35.     dissSlots = diss.size()
  36. end
  37.  
  38.  
  39. function Timer(time)
  40.     os.startTimer(time)
  41.     os.pullEvent("timer")
  42. end
  43.  
  44. --MAIN--
  45. while true do
  46.     local dissData = diss.getItemDetail(1)
  47.     local dissOutputData = diss.getItemDetail(2)
  48.  
  49.     print("Loop Started")
  50.  
  51.     if not dissData then
  52.         if CheckForChemInBarrel(barrel) then
  53.             PushItems()
  54.             print("Items have been put in")
  55.         else
  56.             print("Barrel has no Items")
  57.         end
  58.     else
  59.         print("Dissolver has Items")
  60.     end
  61.  
  62.     if dissOutputData then
  63.         print("Item is being transfered to Output Chest")
  64.         PushItemsToOutput()
  65.     end
  66.  
  67.     Timer(5)
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement