Advertisement
StuBob

SugarFarm computercraft.

Mar 13th, 2015
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. enabled = true
  2. col_length = 15
  3. length = 5
  4.  
  5.  
  6. function rowEnd()
  7. turtle.turnLeft()
  8. go()
  9. go()
  10. turtle.turnLeft()
  11. end
  12.  
  13.  
  14. function lineEnd()
  15. turtle.turnRight()
  16. go()
  17. turtle.turnRight()
  18. end
  19.  
  20.  
  21. function line()
  22. for i=1, col_length do
  23. go()
  24. end
  25. end
  26.  
  27.  
  28. function go()
  29. if turtle.detect() then
  30. turtle.dig()
  31. end
  32. turtle.forward()
  33. print("fuel: " .. turtle.getFuelLevel())
  34. harvest()
  35. end
  36.  
  37.  
  38. function harvest()
  39. turtle.suckDown()
  40. turtle.suckUp()
  41. turtle.suck()
  42. end
  43.  
  44.  
  45. function goHome()
  46. turtle.turnRight()
  47. for i = 1, (length * 3) - 2 do
  48. go()
  49. end
  50. turtle.turnRight()
  51. end
  52.  
  53.  
  54. function dock()
  55. --bank
  56. for i = 16,1,-1 do
  57. turtle.select(i)
  58. turtle.dropDown()
  59. end
  60. --refuel
  61.  
  62. --wait for growth
  63. while (not turtle.detect() and (not detectRight())) do
  64. print('waiting for growth...')
  65. sleep(10)
  66. end
  67. end
  68.  
  69.  
  70. function detectRight()
  71. turtle.turnRight()
  72. isThere = turtle.detect()
  73. turtle.turnLeft()
  74. return isThere
  75. end
  76.  
  77.  
  78.  
  79. while enabled do
  80. if (turtle.getFuelLevel() > 150) then
  81. for i = 1, length do
  82. line()
  83. lineEnd()
  84. line()
  85. if(i ~= length) then
  86. rowEnd()
  87. end
  88. end
  89. goHome()
  90. dock()
  91. else
  92. enabled = false
  93. print('out of fuel T.T')
  94. end
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement