Advertisement
zPandro

orbHandler 2.0

Jul 5th, 2021 (edited)
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. local SLOT_COUNT = 16
  2. local E_Orb = peripheral.wrap("bottom")
  3.  
  4. function itemsDroppable(orb)
  5.     item = orb.getItemDetail(2)
  6.     if(item == nil) then
  7.         for slot = 1, SLOT_COUNT, 1 do
  8.             local item = turtle.getItemDetail(slot)
  9.             if(item ~= nil) then
  10.                 return true
  11.             end
  12.         end
  13.     else
  14.         return false
  15.     end
  16. end
  17.  
  18.  
  19. function dropItems(orb)
  20.     for slot = 1, SLOT_COUNT, 1 do
  21.         local item = turtle.getItemDetail(slot)
  22.         if(item ~= nil) then
  23.             if (item["name"] == "minecraft:redstone_block") then
  24.                 turtle.select(slot)
  25.                 turtle.dropDown(2)
  26.             else
  27.                 turtle.select(slot)
  28.                 turtle.dropDown(1)
  29.             end
  30.         end
  31.     end
  32. end
  33.  
  34. function handleResults(orb)
  35.     while true do
  36.         resultSlot = orb.getItemDetail(1)
  37.         if (resultSlot ~= nil) then
  38.             turtle.select(16)
  39.             turtle.suckDown()
  40.             turtle.dropUp()
  41.             turtle.select(1)
  42.             break
  43.         end
  44.     end
  45. end
  46.  
  47. function getLoops(orb)
  48.     item = orb.getItemDetail(2)
  49.     maxLoops = 0
  50.     if(item == nil) then
  51.         for slot = 1, SLOT_COUNT, 1 do
  52.             local item = turtle.getItemDetail(slot)
  53.             if(item ~= nil) then
  54.                 if (item["count"]) then
  55.                     maxLoops = item["count"]
  56.                 end
  57.             end
  58.         end
  59.     end
  60.     return maxLoops
  61. end
  62.  
  63. while true do
  64.     --local event, p1 = os.pullEvent("turtle_inventory")
  65.     if (itemsDroppable(E_Orb)) then
  66.         dropItems(E_Orb)
  67.         handleResults(E_Orb)
  68.     end
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement