Advertisement
DustinRosebery

rubberTurtleFarm 1.1.2

Nov 1st, 2013
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. deletelocal 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, 1, 4 do
  50.         t.dig()
  51.         up(1)
  52.     end
  53. end
  54.  
  55. local function rowDown()
  56.     for i = 1, 1, 4 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.         end
  76.         else if facing == false then
  77.             forward(1)
  78.             lTurn(1)
  79.             if height == true then
  80.                 rowUp()
  81.             else
  82.                 rowDown()
  83.             end
  84.         end
  85.     end
  86. end
  87.  
  88. local function gotoHome()
  89.     back(2)
  90.     lTurn(1)
  91.     forward(1)
  92.     down(5)
  93.     os.sleep(1)
  94.     rs.setAnalogOutput("left", 15)
  95.     os.sleep(3600)
  96. end
  97.  
  98. while true do  
  99.     gotoStart()
  100.     rowUp()
  101.     harvest(6)
  102.     gotoHome()
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement