Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local zz=turtle
- local args = {...}
- local currentX=0 -- hoz
- local currentY=0 -- height
- local currentZ=0 -- depth
- local currRad=1 -- 0 is the right, 1 is default (original direction), 2 is the left, 3 is the back
- local mapData={{0,16,2,},{0,16,3,},{0,17,4,},{0,17,5,},{0,17,6,},{0,18,7,},{0,19,8,},{0,19,9,},{0,20,10,},{0,21,11,},{0,22,12,},{0,22,13,},{0,17,14,},{0,18,14,},{0,19,14,},{0,23,14,},{0,24,15,},{0,20,15,},{0,19,15,},{0,21,16,},{0,22,16,},{0,23,16,},{0,24,16,},{0,24,17,},{0,23,17,}} -- {y,x,z,slotID}
- local cacheSlot = {}
- function placeUp(slotID)
- for i=1,12 do
- zz.select(i)
- if zz.compareTo(slotID) then
- return zz.placeUp()
- end
- end
- return false
- end
- function refuel(amount)
- while zz.getFuelLevel()<=math.abs(amount) do
- zz.select(16)
- zz.refuel(1)
- print("Refueling")
- end
- end
- function turnRight()
- while zz.turnRight() do
- currRad=(currRad-1)%4
- break
- end
- end
- function turnLeft()
- while zz.turnLeft() do
- currRad=(currRad+1)%4
- break
- end
- end
- function turnToRad(r)
- if currRad==r then
- return true
- end
- while currRad~=r do
- if currRad>r then
- turnRight()
- elseif currRad<r then
- turnLeft()
- end
- end
- end
- function alertForProblem(stringCauseOfProblem)
- zz.turnRight()
- zz.turnRight()
- zz.turnRight()
- zz.turnRight()
- print(stringCauseOfProblem)
- end
- function moveByX(ox)
- local x=currentX+ox
- turnToRad(0)
- refuel(ox)
- while ox~=0 do
- if ox<0 then
- if zz.back() then
- ox=ox+1
- currentX=currentX-1
- else
- alertForProblem("can not move - check fuel or obstacle")
- moveByX(ox)
- break
- end
- else
- if zz.forward() then
- ox=ox-1
- currentX=currentX+1
- else
- alertForProblem("can not move - check fuel or obstacle")
- moveByX(ox)
- break
- end
- end
- end
- end
- function moveByZ(oz)
- local z=currentZ+oz
- turnToRad(1)
- refuel(oz)
- while oz~=0 do
- if oz<0 then
- if zz.back() then
- oz=oz+1
- currentZ=currentZ-1
- else
- alertForProblem("can not move - check fuel or obstacle")
- moveByZ(oz)
- break
- end
- else
- if zz.forward() then
- oz=oz-1
- currentZ=currentZ+1
- else
- alertForProblem("can not move - check fuel or obstacle")
- moveByZ(oz)
- break
- end
- end
- end
- end
- function moveByY(oy)
- local y=currentY+oy
- refuel(oy)
- while oy~=0 do
- if oy<0 then
- if zz.down() then
- oy=oy+1
- currentY=currentY-1
- else
- alertForProblem("can not move down - check fuel or obstacle")
- moveByY(oy)
- break
- end
- else
- if zz.up() then
- oy=oy-1
- currentY=currentY+1
- else
- alertForProblem("can not move up - check fuel or obstacle")
- moveByY(oy)
- break
- end
- end
- end
- end
- function goToCord(y,x,z)
- local differenceX=x-(currentX)
- local differenceY=y-currentY
- local differenceZ=z-currentZ
- if differenceX~=0 then moveByX(differenceX) end
- if differenceY~=0 then moveByY(differenceY) end
- if differenceZ~=0 then moveByZ(differenceZ) end
- end
- function placeAt(y,x,z,slotID)
- goToCord(y,x,z)
- if placeUp(slotID) then return true
- else
- alertForProblem("can not place underneath - must be air underneath or do I have a block to place")
- placeAt(y,x,z,slotID)
- end
- end
- function progressionPlace(startAt)
- for i=15,222 do
- local result=placeAt(14-i,0,0,15)
- if result then print("Finished Task #"..i.." out of "..222) end
- end
- goToCord(0,0,0);
- end
- if (#args==1) then
- progressionPlace(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement