Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- --slot id:
- --1 = mining well, 2=tesseract wtih shiny dust, 3 pipes
- print("Dont forget to shiny dust the tesseract to retain their setting upon destroy");
- function unloadSystems()
- turtle.up();
- turtle.up();
- turtle.select(2);
- turtle.place();
- turtle.down();
- turtle.select(1);
- turtle.place();
- end
- function dumpAllItems()
- for i=1,16 do
- local data = turtle.getItemDetail(i);
- if data then
- repeat
- turtle.select(i);
- until turtle.dropUp();
- end
- end
- end
- function isStillWorking()
- return peripheral.call("front","hasWork")
- end
- 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 cacheSlot = {}
- function place(slotID)
- zz.select(slotID)
- if zz.getItemCount()>0 then
- return zz.place()
- end
- return false
- end
- function placeUp(slotID)
- zz.select(slotID)
- if zz.getItemCount()>0 then
- return zz.placeUp()
- 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 place(slotID) then return true
- else
- alertForProblem("can not place ahead - must be air ahead or do I have a material to place")
- placeAt(y,x,z,slotID)
- end
- end
- function placeUpAt(y,x,z,slotID)
- goToCord(y,x,z)
- if placeUp(slotID) then return true
- else
- alertForProblem("can not place up - must be air ahead or do I have a material to place")
- placeUpAt(y,x,z,slotID)
- end
- end
- local repeatUntil=1;
- if (#args==1) and tonumber(args[1])>1 then
- repeatUntil=tonumber(args[1]);
- end
- for zd=1,repeatUntil do
- unloadSystems()
- os.sleep(1);
- repeat
- until not isStillWorking();
- dumpAllItems();
- turtle.select(1);
- turtle.dig();
- turtle.up();
- turtle.select(2);
- turtle.dig();
- turtle.down();
- turtle.down();
- if repeatUntil>1 then
- turtle.forward();
- end
- end
- print("done");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement