Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args={...}
- function placeForward(blockCount,offset)
- local countAll={}
- local consumed={}
- for i=1,16 do countAll[i]=turtle.getItemCount(i) end
- for i=1,blockCount do
- if turtle.detect() then
- local found=false
- turtle.dig()
- for l=1,16 do
- local c=turtle.getItemCount(l)
- if countAll[l]~=c then
- countAll[l]=c
- consumed[i]=l
- found=true
- break
- end
- end
- if not found then
- consumed[i]=-1
- end
- else
- consumed[i]=-1
- end
- while not turtle.forward() do
- print("blocked")
- end
- end
- for i=1,offset-1 do
- while not turtle.forward() do
- print("blocked")
- end
- end
- for i=1,blockCount do
- if consumed[blockCount+1-i]~=-1 then
- turtle.select(consumed[blockCount+1-i])
- turtle.place()
- end
- while not turtle.back() do
- print("blocked")
- end
- end
- for i=1,offset-1 do
- while not turtle.back() do
- print("blocked")
- end
- end
- end
- if table.getn(args) ~= 4 then
- print("arguments 'blockCount', 'offset', 'x' and 'y' expected")
- else
- local blockCount=tonumber(args[1])
- local offset=tonumber(args[2])
- local X=tonumber(args[3])
- local Y=tonumber(args[4])
- for y=1,Y do
- for x=1,X do
- placeForward(blockCount,offset)
- if x~=X then
- turtle.turnRight()
- while not turtle.forward() do
- print("blocked")
- end
- turtle.turnLeft()
- end
- end
- turtle.turnLeft()
- for x=1,X-1 do
- while not turtle.forward() do
- print("blocked")
- end
- end
- turtle.turnRight()
- if y~=Y then
- while not turtle.up() do
- print("blocked")
- end
- end
- end
- for y=1,Y-1 do
- while not turtle.down() do
- print("blocked")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement