Advertisement
DustinRosebery

rubberTurtleFarm 1.3.1

Nov 1st, 2013
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local t = turtle
  2.  
  3. local function forward(x)
  4.     for i = 1, x do
  5.         t.forward()
  6.     end
  7. end
  8.  
  9. local function rTurn(x)
  10.     for i = 1, x do
  11.         t.turnRight()
  12.     end
  13. end
  14.  
  15. local function lTurn(x)
  16.     for i = 1, x do
  17.         t.turnLeft()
  18.     end
  19. end
  20.  
  21. local function up(x)
  22.     for i = 1, x do
  23.         t.up()
  24.     end
  25. end
  26.  
  27. local function down(x)
  28.     for i = 1, x do
  29.         t.down()
  30.     end
  31. end
  32.  
  33. local function back(x)
  34.     for i = 1, x do
  35.         t.back()
  36.     end
  37. end
  38.  
  39. local function gotoStart()
  40.     rs.setAnalogOutput("left", 0)
  41.     os.sleep(1)
  42.     up(2)
  43.     back(1)
  44.     lTurn(1)
  45.     forward(1)
  46. end
  47.  
  48. local function rowUp()
  49.     for i = 1, 4, 1 do
  50.         t.dig()
  51.         up(1)
  52.     end
  53. end
  54.  
  55. local function rowDown()
  56.     for i = 1, 4, 1 do
  57.         t.dig()
  58.         down(1)
  59.     end
  60. end
  61.  
  62. local facing = t.detect()
  63.  
  64. local height = t.detect(down)
  65.  
  66. local function harvest(x)
  67.     for i = 1, x do
  68.         rTurn(1)
  69.             if facing == true then
  70.                 if height == true then
  71.                     rowUp()
  72.                 else
  73.                     rowDown()
  74.                 end
  75.             else
  76.                 if height == true then
  77.                     forward(1)
  78.                     lTurn(1)
  79.                     rowUp()
  80.                 else
  81.                     forward(1)
  82.                     lTurn(1)
  83.                     rowDown()
  84.                 end
  85.             end
  86.     end
  87. end
  88.        
  89. local function gotoHome()
  90.     back(2)
  91.     lTurn(1)
  92.     forward(1)
  93.     down(5)
  94.     os.sleep(1)
  95.     rs.setAnalogOutput("left", 15)
  96.     os.sleep(3600)
  97. end
  98.  
  99. while true do  
  100.     gotoStart()
  101.     rowUp()
  102.     harvest(6)
  103.     gotoHome()
  104. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement