Advertisement
LoviinWaffles

Turtle Carrot/Potato Farm

May 22nd, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. local function Plant()
  2.     turtle.select(1)
  3.     turtle.placeDown()
  4. end
  5.  
  6. local function Till()
  7.     turtle.digDown()
  8.     turtle.placeDown()
  9. end
  10.  
  11. local function Farm()
  12.     turtle.digDown()
  13.     turtle.suckDown()
  14.     turtle.down()
  15.     turtle.suck()
  16.     turtle.turnLeft()
  17.     turtle.suck()
  18.     turtle.turnLeft()
  19.     turtle.suck()
  20.     turtle.turnLeft()
  21.     turtle.suck()
  22.     turtle.turnLeft()
  23.     turtle.up()
  24.     turtle.digDown()
  25.     Plant()
  26. end
  27.  
  28. local function Search()
  29. success, data = turtle.inspectDown()
  30.     if success == true then
  31.         if data.metadata == 7 then
  32.     Farm()
  33.         end
  34.         else Till()
  35.     end
  36. end
  37.  
  38. local function TurnRight()
  39.     turtle.turnRight()
  40.     turtle.forward()
  41.     turtle.turnRight()
  42.     Search()
  43. end
  44.  
  45. local function TurnLeft()
  46.     turtle.turnLeft()
  47.     turtle.forward()
  48.     turtle.turnLeft()
  49.     Search()
  50. end
  51.  
  52.  
  53. local function ForwardRight()
  54.     while turtle.detect() == false do
  55.         turtle.forward()
  56.         Search()
  57.     end
  58.         TurnRight()
  59. end
  60.  
  61. local function ForwardLeft()
  62.     while turtle.detect() == false do
  63.         turtle.forward()
  64.         Search()
  65.     end
  66.         TurnLeft()
  67. end
  68.  
  69. local function DownBack()
  70.     ForwardRight()
  71.     ForwardLeft()
  72. end
  73.  
  74. local function GoBack()
  75.     while turtle.detect() == false do
  76.         turtle.forward()
  77.         Search()
  78.     end
  79.         turtle.turnRight()
  80.         while turtle.detect() == false do
  81.             turtle.forward()
  82.         end
  83.             turtle.turnLeft()
  84.             turtle.forward()
  85.             turtle.turnRight()
  86.             turtle.select(1)
  87.             turtle.dropDown()
  88.         for a= 2, 16 do
  89.         turtle.select(a)
  90.         turtle.drop()
  91.     end
  92.     turtle.turnRight()
  93. end
  94.  
  95. local function Setup()
  96.     turtle.select(1)
  97.     turtle.suckDown()
  98. end
  99.  
  100.  
  101.  
  102. local function Core()
  103.     Setup()
  104.     DownBack()
  105.     DownBack()
  106.     DownBack()
  107.     DownBack()
  108.     DownBack()
  109.     DownBack()
  110.     DownBack()
  111.     DownBack()
  112.     ForwardRight()
  113.     GoBack()
  114.     sleep(1200)
  115.  
  116. end
  117.  
  118. n=0
  119.  
  120. while n==0 do
  121.     Core()
  122. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement