Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tArgs = {...}
- local length, height, width
- if #tArgs ~= 3 then
- print("Invalid number of arguments. Needs length, width, height")
- else
- length = tonumber(tArgs[1])
- width = tonumber(tArgs[2])
- height = tonumber(tArgs[3])
- end
- term.clear()
- mt = {}
- count = 1
- function look(y,x)
- mt[count] = turtle.detectDown()
- end
- function place(y,x)
- while turtle.getItemCount(1) == 1 do
- res.resupply(1)
- sleep(5)
- end
- if mt[count] then
- turtle.placeDown()
- end
- end
- function scan()
- for y = 1,width do
- for xx = 1,length-1 do
- x = xx
- if y%2 == 0 then
- x = length - xx
- end
- look(y,x)
- forward()
- end
- if y < width then
- if y%2 ~= 0 then
- turtle.turnRight()
- look(y,length)
- forward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- look(y,1)
- forward()
- turtle.turnLeft()
- end
- end
- end
- end
- function fill()
- for z = 1,height do
- count = 1
- for y = 1,width do
- for xx = 1,length-1 do
- x = xx
- if y%2 == 0 then
- x = length - xx
- end
- place(y,x)
- forward()
- end
- if y < width then
- if y%2 ~= 0 then
- turtle.turnRight()
- place(y,length)
- forward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- place(y,1)
- forward()
- turtle.turnLeft()
- end
- end
- end
- turtle.up()
- returnToStart()
- end
- end
- function returnToStart()
- if width%2 ~= 0 then
- turtle.turnRight()
- turtle.turnRight()
- for x = 1,length-1 do
- forward()
- end
- end
- turtle.turnRight()
- for y = 1,width-1 do
- forward()
- end
- turtle.turnRight()
- end
- function forward()
- while turtle.getFuelLevel() < 100 do
- turtle.select(2)
- turtle.refuel(63)
- res.resupply(2)
- turtle.select(1)
- sleep(5)
- end
- while not turtle.forward() do sleep(0.5) end
- count = count + 1
- end
- write("Establishing link to resupply module... ")
- res = peripheral.wrap("left")
- res.link()
- print("Done")
- write("Scanning pattern...")
- scan()
- print("Done")
- print("Placing blocks")
- returnToStart()
- turtle.up()
- fill()
- for i = 1,height+1 do turtle.down() end
- term.setCursorPos(0,length+2)
Advertisement
Add Comment
Please, Sign In to add comment