Ignius12

road

Jan 14th, 2021 (edited)
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. function dig(width, height)
  2.     local x = 0
  3.     local y = 0
  4.  
  5.     while(y < height) do
  6.  
  7.         while(x < width - 1) do
  8.             turtle.dig()
  9.             turtle.forward()
  10.             x = x + 1
  11.         end
  12.  
  13.         turtle.digUp()
  14.         turtle.up()
  15.         turtle.turnLeft()
  16.         turtle.turnLeft()
  17.         y = y + 1
  18.         x = 0
  19.     end
  20.  
  21.     if(height % 2 > 0) then
  22.         while(x > 0) do
  23.             turtle.back()
  24.             x = x - 1
  25.         end
  26.         turtle.turnLeft()
  27.     else
  28.         turtle.turnRight()
  29.     end
  30.     while(y > 0) do
  31.         turtle.down()
  32.         y = y - 1
  33.     end
  34.  
  35. end
  36.  
  37. print("Height?")
  38. local height = tonumber(read())
  39. print("Width?")
  40. local width = tonumber(read())
  41. print("Length?")
  42. local length = tonumber(read())
  43.  
  44. local z = 0
  45.  
  46. turtle.turnRight()
  47.  
  48. while(z < length) do
  49.     dig(width, height)
  50.     turtle.dig()
  51.     turtle.forward()
  52.     turtle.turnRight()
  53.     z = z + 1
  54. end
Add Comment
Please, Sign In to add comment