Lukyrouge22

cc dig

May 31st, 2021 (edited)
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. -- Hole Digger by dillmo --
  2. --[[
  3. This program will dig a hole of your description and place ladders for
  4. you. To begin with, place your mining turtle in the bottom left corner of
  5. your hole. Be sure to place ladders in slot one of your turtle's
  6. inventory and specify configuration variables before beginning.
  7. --]]
  8.  
  9. -- Configuration --
  10. local current_height = 70 -- The current y value of your turtle. This should be
  11. -- the y value of your feet, not your head.
  12.  
  13. local desired_height = 67 -- The y value you want to dig down to.
  14.  
  15. local length = 4 -- The length of your hole. Your turtle is facing
  16. -- this way.
  17.  
  18. local width = 5 -- The width of your hole. This should be
  19. -- perpendicular to the direction your turtle is
  20. -- facing.
  21.  
  22. -- Function Definitions --
  23. local function turnAround()
  24. turtle.turnRight()
  25. turtle.turnRight()
  26. end
  27.  
  28. -- Program --
  29. for i = desired_height, current_height - 1 do
  30. if width % 2 == 0 then
  31. middle_of_width = width / 2
  32. else
  33. middle_of_width = width / 2 + 0.5
  34. end
  35. turtle.digDown()
  36. turtle.down()
  37. for i2 = 1, width do
  38. if i2 == middle_of_width then
  39. for i3 = 2, length do
  40. turtle.dig()
  41. turtle.forward()
  42. end
  43. turnAround()
  44. for i3 = 3, length do
  45. turtle.forward()
  46. end
  47. turtle.select(1)
  48. turtle.place()
  49. turtle.turnLeft()
  50. turtle.dig()
  51. turtle.forward()
  52. turtle.turnRight()
  53. turtle.dig()
  54. turtle.forward()
  55. turnAround()
  56. else
  57. for i3 = 2, length do
  58. turtle.dig()
  59. turtle.forward()
  60. end
  61. turnAround()
  62. for i3 = 2, length do
  63. turtle.forward()
  64. end
  65. turnAround()
  66. if i2 < width then
  67. turtle.turnRight()
  68. turtle.dig()
  69. turtle.forward()
  70. turtle.turnLeft()
  71. end
  72. end
  73. if i2 == width then
  74. turtle.forward()
  75. turtle.turnLeft()
  76. for i3 = 2, width do
  77. turtle.forward()
  78. end
  79. turtle.turnLeft()
  80. turtle.forward()
  81. turnAround()
  82. end
  83. end
  84. end
Add Comment
Please, Sign In to add comment