Guest User

broken turtle code

a guest
Jan 14th, 2022
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.83 KB | None | 0 0
  1. width = 0;
  2. length = 0;
  3. height = 0;
  4. depth = 0;
  5. fuel = turtle.getFuelLevel();
  6. range = 999999;
  7.  
  8. -- get size
  9. while (height == 0) do
  10.     io.write("\nHow high would you like to mine?\n")
  11.     height = io.read()
  12.     range = (((width * (length - 1)) * height) + height);
  13.     print(range);
  14. end
  15. while (width == 0) do
  16.     io.write("\nhow wide would you like the hole to be?\n")
  17.     width = io.read()
  18. end
  19. while (length == 0) do
  20.     io.write("\nHow long would you like the hole to be?\n")
  21.     io.write("\n(Minimum length of 2)\n")
  22.     length = io.read()
  23. end
  24.  
  25. -- dig funcs to lower code written
  26. function digF() --dig forward & move
  27.     turtle.dig()
  28.     turtle.forward()
  29. end
  30. function layerup(depth) -- dig up & move
  31.     turtle.digUp()
  32.     turtle.up()
  33.     depth = depth + 1;
  34.     return depth;
  35. end
  36. function digL(width)
  37.     turtle.turnLeft()
  38.     digF()
  39.     turtle.turnLeft()
  40.     for i=1, (width - 1) do
  41.         digF()
  42.     end
  43. end
  44. function digR(width)
  45.     turtle.turnRight()
  46.     digF()
  47.     turtle.turnRight()
  48.     for i=1, (width - 1) do
  49.         digF()
  50.     end
  51. end
  52.  
  53. -- troubleshooting code, pls ignore
  54. function layer0(width, length)
  55.     digL(width)
  56.     digR(width)
  57. end
  58. function layer1(width, length)
  59.     digR(width)
  60.     digL(width)
  61. end
  62.  
  63. -- initialize, runs once at start
  64. digF()
  65. turtle.turnRight()
  66. for i=1, (width - 1) do
  67.     digF()
  68. end
  69.  
  70. -- main digging function, it all comes together
  71. print("\nMining a hole: \n", width, " blocks wide\n")
  72. print(length, " blocks deep\n", height, " blocks high")
  73.  
  74. sheight = height + 0
  75. while (depth < height) do
  76.     if ((length - 1)%2 == 1) then
  77.         for i=1, ((length)/2) do
  78.             layer0(width, length)
  79.         end
  80.         digL(width)
  81.     end
  82.     depth = layerUp(depth);
  83. end
  84.  
  85. -- MC, RTB
  86. print("\nMission complete, returning!\n")
  87. for i=1, depth do
  88.     turtle.down()
  89. end
  90.  
Advertisement
Add Comment
Please, Sign In to add comment