Advertisement
Tanoro

Turtle Break Trail

Feb 23rd, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. -- pastebin get Xr2JU3p8 breakBox
  2.  
  3. print("Put an item for me to detect in slot #1.")
  4. print("Put coal in slot #16.")
  5. print("Type 'Start' when ready")
  6.  
  7. local go = io.read()
  8.  
  9. local selected = 1
  10. local fuel = 16
  11.  
  12. --[[
  13. * Check to see if refueling is needed
  14. ]]
  15. local function ifRefuel()
  16. if turtle.getFuelLevel() < 1 then
  17. turtle.select(fuel)
  18. turtle.refuel(1)
  19. turtle.select(selected)
  20. end
  21. end
  22.  
  23. if go == "Start" then
  24. -- Select the starting cell
  25. turtle.select(selected)
  26.  
  27. while true do
  28. ifRefuel()
  29.  
  30. if turtle.compare() then
  31. -- Block detected
  32. turtle.dig()
  33. turtle.forward()
  34. else
  35. -- Look around
  36. turtle.turnLeft()
  37.  
  38. if turtle.compare() then
  39. -- Found the next path; Continue
  40. turtle.dig()
  41. turtle.forward()
  42. else
  43. turtle.turnRight()
  44. turtle.turnRight()
  45.  
  46. if turtle.compare() then
  47. turtle.dig()
  48. turtle.forward()
  49. else
  50. -- We're done!
  51. break
  52. end
  53. end
  54. end
  55. end
  56.  
  57. print("Done!")
  58. else
  59. print("Terminating")
  60. return
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement