Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to check if water is empty
- function isWaterEmpty()
- return turtle.getItemCount(1) == 0
- end
- -- Function to perform the right-click loop
- function rightClickLoop()
- while turtle.getItemDetail(1).damage < 1000 do
- turtle.placeDown()
- turtle.digDown()
- os.sleep(0.5) -- Adjust sleep time based on the speed of the action
- end
- end
- -- Main program
- local home = vector.new(-99, 63, 288)
- local wateringPosition = vector.new(-99, 63, 289)
- while true do
- local currentPosition = vector.new(gps.locate(5))
- local displacement = currentPosition - home
- -- If water is empty, go to the watering position and perform the right-click loop
- if isWaterEmpty() then
- local moveVector = wateringPosition - currentPosition
- turtle.turnTo(moveVector.x, moveVector.z)
- turtle.forward(moveVector.magnitude)
- rightClickLoop()
- end
- -- Move to the original starting position and perform the right-click loop
- local moveVector = home - currentPosition
- turtle.turnTo(moveVector.x, moveVector.z)
- turtle.forward(moveVector.magnitude)
- rightClickLoop()
- end
Advertisement
Add Comment
Please, Sign In to add comment