overshoot

Turtle Harvest Row of 10 Cane 3FE6ZNaq

Feb 16th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. -- Harvest Rows of Cane
  2. -- 170218 Upgraded to three sets
  3.  
  4. RowLength=10
  5. NumSetsCrop=3
  6. NumMinHarvest=10
  7.  
  8.  
  9. -- Function to Connect to Monitor
  10. local mon
  11. local function findMonitor()
  12. mon=peripheral.wrap("right")
  13. -- mon.write("Test 1")
  14.  
  15. if peripheral.wrap("right") then
  16. mon.setTextScale(3)
  17. mon.write("Initialized")
  18. return true
  19. else
  20. return false
  21. end
  22. end -- Function find monitor
  23.  
  24. function GetIntoPos()
  25. turtle.up()
  26. turtle.up()
  27. end -- function GetIntoPos()
  28.  
  29. function HarvestRow()
  30. for x=1,10,1 do
  31. turtle.dig()
  32. turtle.forward()
  33. end -- RowLength loop
  34. end -- function HarvestRow
  35.  
  36. function TurnBackLeft()
  37. turtle.turnLeft()
  38. turtle.forward()
  39. turtle.dig()
  40. turtle.forward()
  41. turtle.turnLeft()
  42. end -- function TurnBackLeft
  43.  
  44. function TurnBackRight()
  45. turtle.turnRight()
  46. turtle.forward()
  47. turtle.dig()
  48. turtle.turnRight()
  49. end -- function TurnBackRigth
  50.  
  51. ----------------------------------
  52. -- Return to home position and lower after pass over all crops
  53. function ReturnHome()
  54. turtle.turnLeft()
  55. turtle.forward()
  56. turtle.forward()
  57.  
  58. if NumSetsCrop>1 then
  59. for x=1,NumSetsCrop-1,1 do
  60. turtle.forward()
  61. turtle.forward()
  62. turtle.forward()
  63. end -- of Number of Sets of Crops
  64. end -- if more than one row of crops
  65.  
  66. turtle.turnLeft()
  67. turtle.down()
  68. end -- function ReturnHome
  69.  
  70. -------------------------------
  71. -- Unload turtle into storage
  72. function UnLoad()
  73. turtle.turnLeft()
  74. for x=1,16,1 do
  75. turtle.drop(x)
  76. end
  77. turtle.turnRight()
  78. end -- function UnLoad
  79.  
  80. --------------------------
  81. -- Harvest a full lap
  82. function HarvestLap()
  83. HarvestRow()
  84. TurnBackLeft()
  85. HarvestRow()
  86.  
  87. TurnBackRight()
  88.  
  89. HarvestRow()
  90. TurnBackLeft()
  91. HarvestRow()
  92.  
  93. TurnBackRight()
  94.  
  95. HarvestRow()
  96. TurnBackLeft()
  97. HarvestRow()
  98. end -- of function HarvestLap
  99.  
  100. function HarvestCrop()
  101. print("Running Harvest Routine")
  102. print("Fuel Level: ", turtle.getFuelLevel())
  103.  
  104. GetIntoPos()
  105. HarvestLap()
  106.  
  107. ReturnHome()
  108.  
  109. HarvestLap()
  110.  
  111. ReturnHome()
  112. UnLoad()
  113. end -- HarvestCrop
  114.  
  115. -------------------------
  116. -- Main Routine
  117. -------------------------
  118. MonExists=findMonitor()
  119. print("Name: ", os.getComputerLabel() )
  120.  
  121. while (turtle.getFuelLevel()>100) do
  122. HarvestCrop()
  123. print("Waiting for Growth")
  124. print("FuelLevel: ", turtle.getFuelLevel())
  125.  
  126. for x=NumMinHarvest,1,-1 do
  127. print("Minutes till Harvest: ", x)
  128. sleep(60)
  129. end -- Number of minutes to wait between harvests
  130. end -- While fuel remaining
  131.  
  132. if turtle.getFuelLevel()<100 then
  133. print("Out of Fuel: ", turtle.getFuelLevel())
  134. end
Advertisement
Add Comment
Please, Sign In to add comment