overshoot

Harvest Crops 170218 XysqBrRd

Mar 18th, 2024 (edited)
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | Gaming | 0 0
  1. -- Harvest Rows of Cane
  2. -- 170218 Upgraded to three sets
  3.  
  4. RowLength=10
  5. NumSetsCrop=3
  6.  
  7. function GetIntoPos()
  8. turtle.up()
  9. turtle.up()
  10. end -- function GetIntoPos()
  11.  
  12. function HarvestRow()
  13. for x=1,10,1 do
  14. turtle.dig()
  15. turtle.forward()
  16. end -- RowLength loop
  17. end -- function HarvestRow
  18.  
  19. function TurnBackLeft()
  20. turtle.turnLeft()
  21. turtle.forward()
  22. turtle.forward()
  23. turtle.dig()
  24. turtle.forward()
  25. turtle.turnLeft()
  26. end -- function TurnBackLeft
  27.  
  28. function TurnBackRight()
  29. turtle.turnRight()
  30. turtle.forward()
  31. turtle.forward()
  32. -- turtle.dig()
  33. turtle.turnRight()
  34. end -- function TurnBackRigth
  35.  
  36. ----------------------------------
  37. -- Return to home position and lower after pass over all crops
  38. function ReturnHome()
  39. turtle.turnLeft()
  40. turtle.forward()
  41. if NumSetsCrop>1 then
  42. for x=1,NumSetsCrop-1,1 do
  43. turtle.forward()
  44. turtle.forward()
  45. turtle.forward()
  46. end -- of Number of Sets of Crops
  47. end -- if more than one row of crops
  48.  
  49. turtle.turnLeft()
  50. turtle.down()
  51. end -- function ReturnHome
  52.  
  53. -------------------------------
  54. -- Unload turtle into storage
  55. function UnLoad()
  56. turtle.turnLeft()
  57. for x=1,16,1 do
  58. turtle.drop(x)
  59. end
  60. turtle.turnRight()
  61. end -- function UnLoad
  62.  
  63. function HarvestLap()
  64. HarvestRow()
  65. TurnBackLeft()
  66. HarvestRow()
  67.  
  68. TurnBackRight()
  69.  
  70. HarvestRow()
  71. TurnBackLeft()
  72. HarvestRow()
  73.  
  74. TurnBackRight()
  75.  
  76. HarvestRow()
  77. TurnBackLeft()
  78. HarvestRow()
  79. end -- of function HarvestLap
  80.  
  81. function HarvestCrop()
  82. print("Running Harvest Routine")
  83. print("Fuel Level: ", turtle.getFuelLevel())
  84.  
  85. GetIntoPos()
  86. HarvestLap()
  87.  
  88. ReturnHome()
  89.  
  90. HarvestLap()
  91.  
  92. ReturnHome()
  93. UnLoad()
  94. end -- HarvestCrop
  95.  
  96. -- Main Routine
  97. print("Name: ", os.getComputerLabel() )
  98.  
  99. while (turtle.getFuelLevel()>100) do
  100. HarvestCrop()
  101. print("Waiting for Growth")
  102. print("FuelLevel: ", turtle.getFuelLevel())
  103. sleep(300)
  104. end
  105.  
  106. if turtle.getFuelLevel()<100 then
  107. print("Out of Fuel: ", turtle.getFuelLevel())
  108. end
Advertisement
Add Comment
Please, Sign In to add comment