Advertisement
bobrandy

Untitled

Jul 16th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. function fuelCheck()
  2. while turtle.getFuelLevel() < 1 do
  3. select(1)
  4. turtle.refuel()
  5. if turtle.getFuelLevel() < 1 then
  6. print("Out of fuel, refuel failed. Please put fuel in slot 1, then press enter to continue!")
  7. read()
  8. end
  9. end
  10. end
  11.  
  12. function forward()
  13. fuelCheck()
  14. if not turtle.forward() then print("Forward Error! Fix issue and press enter to continue!") read() end
  15. end
  16.  
  17. function back()
  18. fuelCheck()
  19. if not turtle.back() then print("Forward Error! Fix issue and press enter to continue!") read() end
  20. end
  21.  
  22. index = 0
  23.  
  24. while not turtle.detect() do
  25. forward()
  26. index = index + 1
  27. print(index)
  28. end
  29. for i=1,index do
  30. back()
  31. end
  32. print("Distance was: "..index.." blocks")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement