Advertisement
Guest User

Hole

a guest
Nov 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. print("Length:")
  2. local length = read()
  3. print("Depth:")
  4. local depth = read()
  5.  
  6. function Turn()
  7.   for i = 1,2 do
  8.     turtle.turnLeft()
  9.   end
  10. end
  11.  
  12. function TurnHalf()
  13.   turtle.turnRight()
  14. end
  15.  
  16. function ChangeY()
  17.   Turn()
  18.   turtle.digDown()
  19.   turtle.down()
  20. end
  21.  
  22. function ChangeYHalf()
  23.   TurnHalf()
  24.   turtle.digDown()
  25.   turtle.down()
  26. end
  27.  
  28. function Branch()
  29.   for i = 1,(length-1) do
  30.     turtle.dig()
  31.     turtle.forward()
  32.   end
  33. end
  34.  
  35. function BranchToLeft()
  36.   turtle.turnLeft()
  37.   turtle.dig()
  38.   turtle.forward()
  39.   turtle.turnLeft()
  40.   Branch()
  41. end
  42.  
  43. function BranchToRight()
  44.   turtle.turnRight()
  45.   turtle.dig()
  46.   turtle.forward()
  47.   turtle.turnRight()
  48.   Branch()
  49. end
  50.  
  51. function Layer()
  52.   if math.fmod(length, 2) ~= 0 then
  53.     Branch()
  54.     for i = 1,((length-1)/2) do
  55.       BranchToRight()
  56.       BranchToLeft()
  57.     end
  58.   else
  59.     Branch()
  60.     for i = 1,((length-2)/2) do
  61.       BranchToRight()
  62.       BranchToLeft()
  63.     end
  64.     BranchToRight()
  65.   end
  66. end
  67.  
  68. for i = 1,(depth-1) do
  69.   Layer()
  70.   if math.fmod(length, 2) ~= 0 then
  71.     ChangeY()
  72.  
  73.   else
  74.     ChangeYHalf()
  75.   end
  76. end
  77. Layer()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement