Advertisement
argaman

DigMass

Jun 17th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. function moveDown(blocks)
  2.     for i=1,blocks do
  3.         turtle.down()
  4.     end
  5. end
  6.  
  7.  
  8. function digAllUp()
  9.     local i = 0
  10.     while (turtle.detectUp()) do
  11.         i = i + 1
  12.         turtle.digUp()
  13.         turtle.up()
  14.     end
  15.     moveDown(i)
  16. end
  17.  
  18. function digAllLine(amount)
  19.     for i=1,amount do
  20.         digAllUp()
  21.         turtle.dig()
  22.         turtle.forward()
  23.     end
  24.     digAllUp()
  25. end
  26.  
  27. function turnNum(num)
  28.     if (num == 1) then
  29.         turtle.turnRight()
  30.         turtle.dig()
  31.         turtle.forward()
  32.         turtle.turnRight()
  33.     else
  34.         turtle.turnLeft()
  35.         turtle.dig()
  36.         turtle.forward()
  37.         turtle.turnLeft()
  38.     end
  39. end
  40.  
  41. function main(width, length)
  42.     local side = 1
  43.     for i=1,length do
  44.         digAllLine(width)
  45.         turnNum(side)
  46.         side = side * -1
  47.     end
  48. end
  49.  
  50. print("width(forward):")
  51. local width = tonumber(read())
  52. print("length(right):")
  53. local length = tonumber(read())
  54.  
  55. main(width, length)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement