Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local landArea = {}
- local a = {}
- local args = {...}
- local xScan = tonumber(args[1])
- local zScan = tonumber(args[2])
- local xPos = 0
- local yPos = 0
- local zPos = 0
- local rotation = 0
- local xDiff = 0
- local yDiff = 0
- local zDiff = 0
- local rotDiff = 0
- local allToZero = false
- local allToZeroCheck = false
- local backTo = false
- function a.goToPlace(x,y,z,rot)
- xDiff = xPos-x
- yDiff = yPos-y
- zDiff = zPos-z
- rotDiff = rotation-rot
- while rotDiff ~= 0 do
- if rotDiff<0 then
- turtle.turnLeft()
- rotDiff = rotDiff+90
- rotation = rotation+90
- end
- if rotDiff>0 then
- turtle.turnRight()
- rotDiff = rotDiff-90
- rotation = rotation-90
- end
- end
- turtle.turnLeft()
- while xDiff ~= 0 do
- if(turtle.detect()) then
- while(turtle.detect()) do
- turtle.digUp()
- turtle.up()
- yPos = yPos+1
- yDiff = yDiff+1
- end
- end
- if xDiff<0 then
- turtle.dig()
- turtle.forward()
- xDiff = xDiff+1
- xPos = xPos+1
- end
- if xDiff > 0 then
- turtle.back()
- xDiff = xDiff-1
- xPos = xPos-1
- end
- end
- turtle.turnRight()
- backTo = false
- if(zDiff>0)then turtle.turnRight() turtle.turnRight() backTo = true end
- while zDiff ~= 0 do
- if zDiff<0 then
- a.checkForStuff()
- turtle.forward()
- turtle.digDown()
- zDiff = zDiff+1
- zPos = zPos+1
- end
- if zDiff>0 then
- a.checkForStuff()
- turtle.forward()
- turtle.digDown()
- zDiff = zDiff-1
- zPos = zPos-1
- end
- end
- if(backTo == true)then turtle.turnRight() turtle.turnRight() end
- while yDiff ~= 0 do
- if yDiff<0 then
- if(turtle.detectUp())then
- turtle.digUp()
- end
- turtle.up()
- yDiff = yDiff+1
- yPos = yPos+1
- end
- if yDiff>0 then
- if(yPos>0)then
- turtle.digDown()
- end
- turtle.down()
- yDiff = yDiff-1
- yPos = yPos-1
- end
- end
- end
- for i=1,xScan do
- landArea[i] = {}
- for x=1,zScan do
- landArea[i][x]=0
- end
- end
- function a.checkForStuff()
- if turtle.detect() then
- while turtle.detect() do
- if(turtle.detectUp()) then
- while(turtle.detectUp()) do
- turtle.digUp()
- end
- end
- turtle.up()
- yPos = yPos+1
- yDiff = yDiff+1
- end
- end
- end
- while(allToZeroCheck == false)do
- allToZero=true
- while(xPos<xScan) do
- while(zPos<zScan) do
- a.checkForStuff()
- turtle.forward()
- zPos = zPos+1
- if (turtle.detectDown()==false) and (yPos>0) then
- while (turtle.detectDown()==false) and (yPos>0)do
- turtle.down()
- yPos=yPos-1
- end
- end
- if(yPos >0)then
- turtle.digDown()
- allToZero = false
- end
- landArea[xPos+1][zPos+1] = yPos
- end
- if(xScan~=1)then
- a.goToPlace(xPos+1,0,0,0)
- else
- a.goToPlace(0,0,0,0)
- end
- end
- a.goToPlace(0,0,0,0)
- print(allToZero)
- allToZeroCheck = allToZero
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement