funkd0ct0r

Untitled

Jan 8th, 2014
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. -- mJ1S30HC
  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 = 15
  10. local growTime = 900
  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. turtle.down()
  68. repeat until not turtle.suckDown()
  69. turtle.up()
  70. turtle.back()
  71. turtle.turnRight()
  72. end
  73.  
  74. local function plant()
  75.  
  76. turtle.select(1)
  77. local curX
  78. local curY
  79.  
  80. curY = 1
  81. while curY <= plotLength do
  82. curX = 1
  83. while curX <= plotWidth do
  84.  
  85. if turtle.getItemCount(1) > 1 then
  86. turtle.placeDown()
  87. end
  88.  
  89. if curX == plotWidth then
  90. if curY < plotLength then
  91. if curY % 2 == 1 then
  92. turtle.turnRight()
  93. repeat until turtle.forward()
  94. turtle.turnRight()
  95. else
  96. turtle.turnLeft()
  97. repeat until turtle.forward()
  98. turtle.turnLeft()
  99. end
  100. end
  101. else
  102. repeat until turtle.forward()
  103. end
  104.  
  105. curX = curX + 1
  106. end
  107. curY = curY + 1
  108. end
  109.  
  110. end
  111.  
  112. while turtle.getItemCount(1) ~= 0 do
  113.  
  114. turtle.select(1)
  115. while turtle.getFuelLevel() < 128 do
  116. while turtle.getItemCount(2) < 2 do
  117. print("Out of Fuel")
  118. sleep(1)
  119. end
  120. turtle.select(2)
  121. turtle.refuel(1)
  122. turtle.select(1)
  123. end
  124.  
  125. resetPosition()
  126. harvest()
  127. plant()
  128. wait(growTime)
  129.  
  130.  
  131. end
Advertisement
Add Comment
Please, Sign In to add comment