BJDNZ

NineMine1

Jun 5th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. function itemInSlot (slot)
  2.     turtle.select(slot)
  3.     local data = turtle.getItemDetail()
  4.     if data then
  5.         return true
  6.     else
  7.         return false
  8.     end
  9. end
  10. function checkForCrop ()
  11.     if turtle.detectDown() then
  12.         local success, data = turtle.inspectDown()
  13.         if success then
  14.             if data.name == "minecraft:wheat" and data.metadata == 7 then
  15.                 turtle.digDown()
  16.                 turtle.select(1)
  17.                 turtle.placeDown()
  18.             end
  19.         end
  20.     else
  21.         turtle.digDown()   
  22.         turtle.select(1)
  23.         turtle.placeDown()
  24.     end
  25. end
  26. function farmRow(rowLength)
  27.     for x=1,rowLength do
  28.         turtle.forward()
  29.         checkForCrop()
  30.     end
  31. end
  32. function chestSort ()
  33.     for x=1,16 do
  34.         if itemInSlot(x) then
  35.             itemData = turtle.getItemDetail()["name"]
  36.             if itemData == "minecraft:log" then
  37.                 print("Fuel detected")
  38.                 turtle.refuel(turtle.getItemCount(x))
  39.             elseif x ~= 1 then
  40.                 turtle.drop()
  41.             end
  42.         end
  43.     end
  44.     return "Chest Sort Complete"
  45. end
  46. while true do
  47.     turtle.turnRight()
  48.     --Zig Zag Begins
  49.     for x=2,9 do
  50.         if x%2 == 0 then
  51.             farmRow(8)
  52.             turtle.turnRight()
  53.             farmRow(1)
  54.             turtle.turnRight()
  55.         else
  56.             farmRow(8)
  57.             turtle.turnLeft()
  58.             farmRow(1)
  59.             turtle.turnLeft()
  60.         end
  61.     end
  62.     -- End sequence to return to base
  63.     farmRow(8)
  64.     turtle.turnLeft()
  65.     farmRow(8)
  66.     turtle.turnLeft()
  67.     farmRow(8)
  68.     turtle.turnRight()
  69.     chestSort()
  70.     os.sleep(10000)
  71. end
Advertisement
Add Comment
Please, Sign In to add comment