Advertisement
HelmedRaven

Turtle Farm

Apr 29th, 2020
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. maxRows = 4
  2. fieldLength = 5
  3. currentRows = 0
  4. direction = 0
  5. position = 0
  6.  
  7. while currentRows < maxRows and turtle.getFuelLevel() ~= 0 do
  8.     if position >= fieldLength then
  9.         position = 0
  10.         if direction == 0 then
  11.             print("Turning to next side...")
  12.             turtle.turnRight()
  13.             turtle.forward()
  14.             turtle.turnRight()
  15.             turtle.forward()
  16.             direction = 1
  17.         else
  18.             print("Moving to next row.")
  19.             turtle.turnLeft()
  20.             turtle.forward()
  21.             turtle.forward()
  22.             turtle.turnLeft()
  23.             turtle.forward()
  24.             direction = 0      
  25.             currentRows = currentRows + 1      
  26.         end
  27.     elseif position < fieldLength then
  28.         turtle.digDown(right)
  29.         turtle.forward()
  30.         position = position + 1
  31.     end
  32. end
  33. print("Farming Complete. Returning...")
  34. turtle.turnRight()
  35. turtle.turnRight()
  36. turtle.forward()
  37. turtle.turnRight()
  38. for i = 0, (maxRows * 3) - 1 do
  39.     turtle.forward()
  40. end
  41. turtle.turnRight()
  42. turtle.forward()
  43. print("Task Complete!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement