lucifersamfr

EssentiaJarProvider

May 21st, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local chest = peripheral.wrap("bottom")
  2. local jarSide= "top"
  3. local aspect = "herba"
  4. local tSlot = 1
  5. local chestToTurtle = "up"
  6. --local cableSide = "bottom"
  7.  
  8. function fullJarSlot()
  9.   local as = chest.getAllStacks(false)
  10.   for slot,content in pairs(as) do
  11.     if content.name == "BlockJarFilledItem" then
  12.       return slot
  13.     end
  14.   end
  15.   return 0
  16. end
  17.  
  18. function placeFullJar()
  19.   local placed = false
  20.   while placed == false do
  21.     turtle.select(tSlot)
  22.     while turtle.getItemCount(tSlot) < 1 do
  23.       local fjs= fullJarSlot()
  24.       if fjs > 0 then
  25.         chest.pushItemIntoSlot(chestToTurtle,fjs,1,tSlot)
  26.       end
  27.       sleep(2)
  28.     end
  29.     while not turtle.detectUp() do
  30.       turtle.select(tSlot)
  31.       placed=turtle.placeUp()
  32.       sleep(4)
  33.     end
  34.     sleep(4)
  35.   end
  36. end
  37.  
  38. while true do
  39.   for i = 1,16 do
  40.     if turtle.getItemCount(i) > 0 then
  41.       turtle.dropDown()
  42.     end
  43.   end
  44.   if turtle.detectUp() then
  45.     local level = peripheral.call(jarSide,"getAspectCount",aspect)
  46.     if level == 0 then
  47.       print("Jar is empty")
  48.       turtle.select(tSlot)
  49.       turtle.digUp()
  50.       turtle.dropDown(1)
  51.     else
  52.       print("Jar not empty yet...")
  53.       sleep(8)
  54.     end
  55.   else
  56.     print("No jar detected")
  57.     placeFullJar()
  58.   end
  59.  
  60. end
Advertisement
Add Comment
Please, Sign In to add comment