Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args={ ... }
- local row = 0
- local col = 0
- if args[1] == "help" then
- print("Usage: lay {right} {ahead} {gaps} {floors}")
- return
- end
- local rows = tonumber(args[1])
- local columns = tonumber(args[2])
- local gaps = tonumber(args[3])
- gaps = gaps+1
- local floors = tonumber(args[4])
- local selected = 16
- local start = "start"
- local direction = "right"
- local floor = 0
- local up = 0
- if columns < 1 then
- columns = 1
- end
- if rows < 1 then
- rows = 1
- end
- if floors < 1 then
- floors = 1
- end
- if gaps < 1 then
- gaps = 3
- end
- while floor < floors do
- gap = 0
- while row < rows do
- while turtle.getItemCount(selected) == 0 do
- selected=selected-1
- if selected == 0 then
- selected = 16
- end
- if selected == 1 then
- if turtle.getItemCount(selected) == 0 then
- selected = 16
- print("Waiting for flooring blocks")
- end
- end
- end
- turtle.select(selected)
- if start == "start" then
- start = "homer"
- else
- turtle.placeDown()
- end
- col=col+1
- if col == columns then
- col=0
- row=row+1
- if row < rows then
- if direction == "right" then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- direction = "left"
- elseif direction == "left" then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- direction = "right"
- end
- end
- end
- if col == 0 then
- col=0
- else
- turtle.forward()
- end
- end
- while gap < gaps do
- gap=gap+1
- turtle.up()
- up = up+1
- end
- if direction == "right" then
- print("final direction is right")
- turtle.turnLeft()
- else
- print("final direction is left")
- turtle.turnRight()
- end
- local backtrack = 1
- while backtrack < rows do
- backtrack = backtrack+1
- turtle.forward()
- end
- if direction == "right" then
- backtrack = 1
- turtle.turnLeft()
- while backtrack < columns do
- backtrack = backtrack+1
- turtle.forward()
- end
- turtle.turnRight()
- turtle.turnRight()
- else
- turtle.turnRight()
- end
- floor = floor+1
- col = 0
- row = 0
- direction = "right"
- end
- local down = 0
- while down < up do
- turtle.down()
- down = down+1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement