Advertisement
rhills

Untitled

Sep 3rd, 2015
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. local args={ ... }
  2. local row = 0
  3. local col = 0
  4. if args[1] == "help" then
  5. print("Usage: lay {right} {ahead} {gaps} {floors}")
  6. return
  7. end
  8.  
  9. local rows = tonumber(args[1])
  10. local columns = tonumber(args[2])
  11. local gaps = tonumber(args[3])
  12. gaps = gaps+1
  13. local floors = tonumber(args[4])
  14. local selected = 16
  15. local start = "start"
  16. local direction = "right"
  17. local floor = 0
  18. local up = 0
  19. if columns < 1 then
  20. columns = 1
  21. end
  22. if rows < 1 then
  23. rows = 1
  24. end
  25. if floors < 1 then
  26. floors = 1
  27. end
  28. if gaps < 1 then
  29. gaps = 3
  30. end
  31. while floor < floors do
  32. gap = 0
  33. while row < rows do
  34. while turtle.getItemCount(selected) == 0 do
  35. selected=selected-1
  36. if selected == 0 then
  37. selected = 16
  38. end
  39. if selected == 1 then
  40. if turtle.getItemCount(selected) == 0 then
  41. selected = 16
  42. print("Waiting for flooring blocks")
  43. end
  44. end
  45. end
  46. turtle.select(selected)
  47. if start == "start" then
  48. start = "homer"
  49. else
  50. turtle.placeDown()
  51. end
  52. col=col+1
  53. if col == columns then
  54. col=0
  55. row=row+1
  56. if row < rows then
  57. if direction == "right" then
  58. turtle.turnRight()
  59. turtle.forward()
  60. turtle.turnRight()
  61. direction = "left"
  62. elseif direction == "left" then
  63. turtle.turnLeft()
  64. turtle.forward()
  65. turtle.turnLeft()
  66. direction = "right"
  67. end
  68. end
  69. end
  70. if col == 0 then
  71. col=0
  72. else
  73. turtle.forward()
  74. end
  75. end
  76. while gap < gaps do
  77. gap=gap+1
  78. turtle.up()
  79. up = up+1
  80. end
  81. if direction == "right" then
  82. print("final direction is right")
  83. turtle.turnLeft()
  84. else
  85. print("final direction is left")
  86. turtle.turnRight()
  87. end
  88. local backtrack = 1
  89. while backtrack < rows do
  90. backtrack = backtrack+1
  91. turtle.forward()
  92. end
  93. if direction == "right" then
  94. backtrack = 1
  95. turtle.turnLeft()
  96. while backtrack < columns do
  97. backtrack = backtrack+1
  98. turtle.forward()
  99. end
  100. turtle.turnRight()
  101. turtle.turnRight()
  102. else
  103. turtle.turnRight()
  104. end
  105. floor = floor+1
  106. col = 0
  107. row = 0
  108. direction = "right"
  109. end
  110. local down = 0
  111. while down < up do
  112. turtle.down()
  113. down = down+1
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement