Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. --[[
  2. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  3. Version 2, December 2004
  4.  
  5. Copyright (C) 2019 Yui <notyui@yui.pet>
  6.  
  7. Everyone is permitted to copy and distribute verbatim or modified
  8. copies of this license document, and changing it is allowed as long
  9. as the name is changed.
  10.  
  11. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  12. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  13.  
  14. 0. You just DO WHAT THE FUCK YOU WANT TO.
  15. ]]--
  16.  
  17. local LEFT = 1
  18. local RIGHT = 0
  19.  
  20. -- CONFIG START --
  21.  
  22. local end_pos = {
  23. x = 17,
  24. y = 60,
  25. z = 17
  26. }
  27.  
  28. local direction = LEFT
  29.  
  30. --- CONFIG END ---
  31.  
  32. local pos = {
  33. x = 0,
  34. y = 0,
  35. z = 0
  36. }
  37.  
  38. function move_forward(steps)
  39. for i = 1, steps do
  40. if turtle.detect() then
  41. turtle.dig()
  42. end
  43.  
  44. turtle.forward()
  45. end
  46. end
  47.  
  48. function turn_left()
  49. turtle.turnLeft()
  50.  
  51. move_forward(1)
  52.  
  53. turtle.turnLeft()
  54. end
  55.  
  56. function turn_right()
  57. turtle.turnRight()
  58.  
  59. move_forward(1)
  60.  
  61. turtle.turnRight()
  62. end
  63.  
  64. function dig_layer()
  65. while pos.z ~= end_pos.z do
  66. move_forward(end_pos.x - 1)
  67.  
  68. pos.z = pos.z + 1
  69. direction = not direction
  70.  
  71. if pos.z ~= end_pos.z then
  72. if direction then
  73. turn_left()
  74. else
  75. turn_right()
  76. end
  77. end
  78. end
  79. end
  80.  
  81. function move_down(steps)
  82. for i = 1, steps do
  83. if turtle.detectDown() then
  84. turtle.digDown()
  85. end
  86.  
  87. turtle.down()
  88. end
  89. end
  90.  
  91. function main()
  92. while pos.y ~= end_pos.y do
  93. dig_layer()
  94.  
  95. pos = {x = 0, y = pos.y + 1, z = 0}
  96. direction = not direction
  97.  
  98. if pos.y ~= end_pos.y then
  99. turtle.turnLeft()
  100. turtle.turnLeft()
  101.  
  102. move_down(1)
  103. end
  104. end
  105. end
  106.  
  107. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement