InsideIntel

Untitled

Jan 12th, 2024
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. -- Function to check if water is empty
  2. function isWaterEmpty()
  3. return turtle.getItemCount(1) == 0
  4. end
  5.  
  6. -- Function to perform the right-click loop
  7. function rightClickLoop()
  8. while turtle.getItemDetail(1).damage < 1000 do
  9. turtle.placeDown()
  10. turtle.digDown()
  11. os.sleep(0.5) -- Adjust sleep time based on the speed of the action
  12. end
  13. end
  14.  
  15. -- Main program
  16. local home = vector.new(-99, 63, 288)
  17. local wateringPosition = vector.new(-99, 63, 289)
  18.  
  19. while true do
  20. local currentPosition = vector.new(gps.locate(5))
  21. local displacement = currentPosition - home
  22.  
  23. -- If water is empty, go to the watering position and perform the right-click loop
  24. if isWaterEmpty() then
  25. local moveVector = wateringPosition - currentPosition
  26. turtle.turnTo(moveVector.x, moveVector.z)
  27. turtle.forward(moveVector.magnitude)
  28. rightClickLoop()
  29. end
  30.  
  31. -- Move to the original starting position and perform the right-click loop
  32. local moveVector = home - currentPosition
  33. turtle.turnTo(moveVector.x, moveVector.z)
  34. turtle.forward(moveVector.magnitude)
  35. rightClickLoop()
  36. end
  37.  
Advertisement
Add Comment
Please, Sign In to add comment