Advertisement
argaman

Untitled

Jun 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 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. return i
  16. end
  17.  
  18. function digAllDown(blocks)
  19. for i=1,blocks do
  20. turtle.digDown()
  21. turtle.down()
  22. end
  23. end
  24.  
  25. function digAllLine(amount)
  26. --dig up then dig down, and if theres an odd number go down when your done
  27. local j = 0
  28. for i=1,amount do
  29. if (i % 2 == 0) then
  30. digAllDown(j)
  31. else
  32. j = digAllUp()
  33. end
  34. turtle.dig()
  35. turtle.forward()
  36. end
  37. if(amount % 2 == 1) then
  38. moveDown(j)
  39. end
  40. end
  41.  
  42. function turnNum(num)
  43. if (num == 1) then
  44. turtle.turnRight()
  45. turtle.dig()
  46. turtle.forward()
  47. turtle.turnRight()
  48. else
  49. turtle.turnLeft()
  50. turtle.dig()
  51. turtle.forward()
  52. turtle.turnLeft()
  53. end
  54. end
  55.  
  56. function main(width, length)
  57. local side = 1
  58. for i=1,length do
  59. digAllLine(width)
  60. turnNum(side)
  61. side = side * -1
  62. end
  63. end
  64.  
  65. print("width(forward):")
  66. local width = tonumber(read())
  67. print("length(right):")
  68. local length = tonumber(read())
  69.  
  70. main(width, length)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement