Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if turtle.getFuelLevel()==0 then
- print("No fuel!")
- return
- end
- local x,y,z,fx,fz=0,0,0,1,0
- local size=2
- local bottomLayer
- local isFull
- turtle.select(1)
- function face(tfx,tfz)
- if tfx==-fz and tfz==fx then
- rt()
- end
- while tfx~=fx or tfz~=fz do
- lt()
- end
- return true
- end
- function goto(tx,ty,tz,txDir,tzDir)
- while y<ty do
- u()
- end
- while y>ty do
- d()
- end
- if x<tx then
- face(1,0)
- repeat
- f()
- until x==tx
- end
- if x>tx then
- face(-1,0)
- repeat
- f()
- until x==tx
- end
- if z<tz then
- face(0,1)
- repeat
- f()
- until z==tz
- end
- if z>tz then
- face(0,-1)
- repeat
- f()
- until z==tz
- end
- if txDir and tzDir then
- face(txDir,tzDir)
- end
- end
- function c()
- if turtle.getItemCount(16)>0 and not isFull then
- local ox,oy,oz,ofx,ofz=x,y,z,fx,fz
- isFull=true
- if ox==0 and oz==0 then
- f()
- end
- goto(0,0,0)
- for e=1,16 do
- turtle.select(e)
- turtle.refuel()
- turtle.dropDown()
- end
- turtle.select(1)
- goto(ox,0,oz)
- goto(ox,oy,oz,ofx,ofz)
- isFull=false
- end
- end
- function f()
- if turtle.detect() and not turtle.dig() then
- bottomLayer=y
- return
- end
- c()
- x=x+fx
- z=z+fz
- while not turtle.forward() do
- turtle.dig()
- sleep(0.5)
- end
- end
- function u()
- y=y+1
- repeat
- turtle.digUp()
- until turtle.up()
- end
- function d()
- if turtle.detectDown() and not turtle.digDown() then
- bottomLayer=y-1
- end
- c()
- repeat
- until turtle.down()
- y=y-1
- end
- function lt()
- fx,fz=fz,-fx
- return turtle.turnLeft()
- end
- function rt()
- fx,fz=-fz,fx
- return turtle.turnRight()
- end
- function layer()
- for i=0,size do
- for j=1,size do
- f()
- if bottomLayer and y==bottomLayer then
- return
- end
- end
- if i<size then
- if i%2==0 then
- rt()
- f()
- rt()
- else
- lt()
- f()
- lt()
- end
- end
- end
- end
- while true do
- goto(-size/2,size/2-1,-size/2,1,0)
- layer()
- for q=2,(bottomLayer and y-bottomLayer or size) do
- d()
- for w=1,4 do
- lt()
- for k=1,size do
- f()
- end
- end
- end
- if not bottomLayer then
- lt()
- lt()
- d()
- end
- if not bottomLayer then --bc d() could create it
- layer()
- end
- size=size+2
- end
Advertisement
Add Comment
Please, Sign In to add comment