Advertisement
DustinRosebery

rubberTurtleFarm 1.5.0

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