Facebook
From DC, 6 Months ago, written in Lua.
Embed
Download Paste or View Raw
Hits: 52
  1. function wait()
  2.     --Anytime in seconds you want
  3.     sleep(15)
  4. end
  5.  
  6. --Harvests potato in front of it then drops all the potatos in selected slot except 1.
  7. function dig()
  8.     turtle.dig()
  9.     turtle.suck()
  10.     turtle.place()
  11.     for i = 1,turtle.getItemCount() - 1, 1 do
  12.         turtle.dropDown()
  13.     end
  14. end
  15.  
  16. --Checks if potato is planted, if so checks if its ready for harvesting
  17. function inspect()
  18.     local booleanValue, potatoInfo = turtle.inspect()
  19.  
  20.     if (not booleanValue) then
  21.         for i = 1, 16, 1 do
  22.             turtle.select(i)
  23.             turtle.getItemDetail(i)
  24.             print(turtle.getItemDetail(i))
  25.             if(turtle.getItemDetail(i) ~= nil) then
  26.                 if (turtle.getItemDetail(i).name == "minecraft:potato") then
  27.                     turtle.place()
  28.                     break
  29.                 end
  30.             end
  31.         end
  32.         turtle.place()
  33.     else
  34.         if (potatoInfo.state.age == 7) then
  35.             dig()
  36.             next()
  37.         else
  38.             wait()
  39.             inspect()
  40.         end
  41.     end
  42. end
  43.  
  44. --Moves forward and checks next potato, if it detects a block in front of it, turns around and goes back to start
  45. function next()
  46.     turtle.turnLeft()
  47.  
  48.     if (turtle.inspect() == false) then
  49.         turtle.forward()
  50.         turtle.turnRight()
  51.         inspect()
  52.     else
  53.         turtle.turnLeft()
  54.         turtle.turnLeft()
  55.  
  56.         while (turtle.inspect() == false) do
  57.             turtle.forward()
  58.         end
  59.  
  60.         turtle.turnLeft()
  61.         inspect()
  62.     end
  63. end
  64.  
  65. inspect()