Advertisement
DustinRosebery

rubberTurtleFarm 1.4.0

Nov 1st, 2013
303
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 upDown()
  67.     if height == true then
  68.         rowUp()
  69.     else
  70.         rowDown()  
  71.  
  72. local function harvest(x)
  73.     for i = 1, x do
  74.         rTurn(1)
  75.         if facing == true then
  76.             upDown()
  77.         else
  78.             forward(1)
  79.             lTurn(1)
  80.             upDown()
  81.         end    
  82.     end
  83. end
  84.        
  85. local function gotoHome()
  86.     back(2)
  87.     lTurn(1)
  88.     forward(1)
  89.     down(5)
  90.     os.sleep(1)
  91.     rs.setAnalogOutput("left", 15)
  92.     os.sleep(3600)
  93. end
  94.  
  95. while true do  
  96.     gotoStart()
  97.     rowUp()
  98.     harvest(6)
  99.     gotoHome()
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement