funkd0ct0r

Untitled

Jan 8th, 2014
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1.  
  2. -- FtP6HvzA up
  3. -- slots: seeds, fuel
  4. -- maybe use glass slabs and an ender chest
  5.  
  6.  
  7. local plotLength = 8
  8. local plotWidth = 8
  9. local harvestTime = 20
  10. local growTime = 1500
  11.  
  12. local useChest = false
  13.  
  14. local function wait(secs)
  15. for sec = secs, 0, -5 do
  16. term.clear()
  17. term.setCursorPos(1,1)
  18. print(sec)
  19. if turtle.getItemCount(1) == 0 then
  20. break
  21. end
  22. sleep(5)
  23. end
  24. term.clear()
  25. end
  26.  
  27. local function resetPosition()
  28. repeat until not turtle.up()
  29. repeat until not turtle.forward()
  30. while turtle.detect() do turtle.turnRight() end
  31.  
  32. while not rs.getInput("left") do
  33. if not turtle.forward() then
  34. turtle.turnRight()
  35. end
  36. end
  37. end
  38.  
  39. local function dropExcess()
  40. for slot = 1, 16 do
  41. if turtle.getItemCount(slot) ~= 0 then
  42. turtle.select(slot)
  43. if slot == 1 then
  44. turtle.drop(turtle.getItemCount(slot) - 1)
  45. elseif slot ~= 2 then
  46. turtle.drop()
  47. end
  48. end
  49. sleep(0)
  50. end
  51. turtle.select(1)
  52. end
  53.  
  54. local function harvest()
  55. rs.setOutput("top", true)
  56. wait(harvestTime)
  57. rs.setOutput("top", false)
  58.  
  59. if useChest then
  60. repeat until turtle.forward()
  61. turtle.turnLeft()
  62. dropExcess()
  63. turtle.turnRight()
  64. end
  65.  
  66. repeat until not turtle.forward()
  67. sleep(1)
  68. turtle.down()
  69. repeat until not turtle.suckDown()
  70. turtle.up()
  71. turtle.back()
  72. turtle.turnRight()
  73. end
  74.  
  75. local function plant()
  76.  
  77. turtle.select(1)
  78. local curX
  79. local curY
  80.  
  81. curY = 1
  82. while curY <= plotLength do
  83. curX = 1
  84. while curX <= plotWidth do
  85.  
  86. if turtle.getItemCount(1) > 1 then
  87. turtle.placeDown()
  88. end
  89.  
  90. if curX == plotWidth then
  91. if curY < plotLength then
  92. if curY % 2 == 1 then
  93. turtle.turnRight()
  94. repeat until turtle.forward()
  95. turtle.turnRight()
  96. else
  97. turtle.turnLeft()
  98. repeat until turtle.forward()
  99. turtle.turnLeft()
  100. end
  101. end
  102. else
  103. repeat until turtle.forward()
  104. end
  105.  
  106. curX = curX + 1
  107. end
  108. curY = curY + 1
  109. end
  110.  
  111. end
  112.  
  113. rs.setOutput("top", false)
  114. while turtle.getItemCount(1) ~= 0 do
  115.  
  116. turtle.select(1)
  117. while turtle.getFuelLevel() < 128 do
  118. while turtle.getItemCount(2) < 2 do
  119. print("Out of Fuel")
  120. sleep(1)
  121. end
  122. turtle.select(2)
  123. turtle.refuel(1)
  124. turtle.select(1)
  125. end
  126.  
  127. resetPosition()
  128. harvest()
  129. plant()
  130. wait(growTime)
  131.  
  132.  
  133. end
Advertisement
Add Comment
Please, Sign In to add comment