Advertisement
mashen456

Untitled

May 3rd, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. -- Strip mining turtle program.
  2. -- mashen *********, mashen ********. 13/12/12
  3.  
  4. --[[fuel must be placed in slot 15,
  5. torches must be placed in slot 16.]]
  6.  
  7. -- Create the function for refueling
  8. function checkFuel()
  9. if turtle.getFuelLevel() <= 10 then
  10. turtle.select(15)
  11. turtle.refuel(1)
  12. turtle.select(1)
  13. end --if
  14. end --checkFuel()
  15.  
  16. -- Create the turnAround function
  17. function turnAround()
  18. turtle.turnRight()
  19. turtle.turnRight()
  20. end --turnAround()
  21.  
  22. -- Digs the tunnel for the given length
  23. function tunnel(givenLength)
  24. local distance = 0
  25. for index = 1,givenLength do
  26. turtle.dig()
  27. if turtle.forward() then
  28. distance = distance + 1
  29. end --if
  30. turtle.digUp()
  31. turtle.select(1)
  32. turtle.placeDown()
  33.  
  34. -- Places a torch every 10 blocks
  35. if distance == 10 then
  36. turtle.select(16)
  37. print("Placing torch...")
  38. turnAround()
  39. turtle.place()
  40. turnAround()
  41. distance = 0
  42. checkFuel()
  43. end --if
  44. end --for
  45.  
  46. -- Sends the turtle back to the start
  47. turtle.up()
  48. for index = 1,givenLength do
  49. turtle.back()
  50. end --for
  51. turtle.down()
  52. end --tunnel()
  53.  
  54. -- Main script
  55. print("Input tunnel length:")
  56. local length = read()
  57. print("starting excavation...")
  58. checkFuel()
  59. tunnel(length)
  60. print("The tunnel has been excavated!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement