Dlog_M125

farm

Jul 20th, 2024 (edited)
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. -- Function to cut crop and plant seed
  2. function cutAndPlant()
  3. turtle.digDown()
  4. turtle.placeDown()
  5. end
  6.  
  7. -- Function to move forward 25 blocks
  8. function moveForward25()
  9. for i = 1, 25 do
  10. cutAndPlant()
  11. if i < 25 then
  12. turtle.forward()
  13. end
  14. end
  15. end
  16.  
  17. -- Function to move to the next row
  18. function moveToNextRow(row)
  19. if row % 2 == 1 then
  20. -- Odd row: turn right, move forward, turn right
  21. turtle.turnRight()
  22. turtle.forward()
  23. turtle.turnRight()
  24. else
  25. -- Even row: turn left, move forward, turn left
  26. turtle.turnLeft()
  27. turtle.forward()
  28. turtle.turnLeft()
  29. end
  30. end
  31.  
  32. -- Function to farm the field
  33. function farmField()
  34. for row = 1, 18 do
  35. moveForward25()
  36. if row < 18 then
  37. moveToNextRow(row)
  38. end
  39. end
  40. end
  41.  
  42. -- Function to return to starting position
  43. function returnToStart()
  44. -- Return to the starting row
  45. turtle.turnRight()
  46. for i = 1, 17 do
  47. turtle.forward()
  48. end
  49. turtle.turnRight()
  50. -- Return to the starting column
  51. for i = 1, 25 do
  52. turtle.forward()
  53. end
  54. turtle.turnRight()
  55. turtle.turnRight() -- Face the original direction
  56. end
  57.  
  58. -- Main loop to continuously farm the field
  59. while true do
  60. farmField()
  61. returnToStart()
  62. -- Sleep for a specified time before starting over (e.g., 10 minutes)
  63. os.sleep(600)
  64. end
  65.  
Add Comment
Please, Sign In to add comment