Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function digU()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- function digF()
- while turtle.detect() do
- turtle.dig()
- end
- end
- function digD()
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- function goU()
- repeat
- digU()
- proofFuel()
- until turtle.up()
- end
- function goF()
- repeat
- digF()
- proofFuel()
- until turtle.forward()
- end
- function goD()
- repeat
- digD()
- proofFuel()
- until turtle.down()
- end
- function status()
- term.clear()
- term.setCursorPos(1,1)
- print("Dig Tunnel:")
- print("")
- print("H: "..height.." W: "..width.." L: "..length)
- print("")
- print(dug.."/"..blocks.." dug, "..(blocks-dug).." left.")
- end
- function proofFuel()
- if turtle.getFuelLevel()==0 then
- turtle.select(16)
- while turtle.refuel(1)==false do
- term.clear()
- term.setCursorPos(1,1)
- print("Dig tunnel:")
- print("")
- print("Put coal on slot 16.")
- os.sleep(4)
- turtle.select(16)
- end
- turtle.select(1)
- end
- end
- function place()
- if not turtle.detectDown() then
- if turtle.getItemCount(1)>1 then
- turtle.placeDown()
- return
- end
- for i=2,13 do
- if turtle.compareTo(i) then
- turtle.select(i)
- turtle.placeDown()
- turtle.select(1)
- return
- end
- end
- end
- end
- function invFull()
- for i=1,13 do
- if turtle.getItemCount(i)==0 then
- return false
- end
- end
- return true
- end
- turtle.select(1)
- term.clear()
- term.setCursorPos(1,1)
- print("Dig tunnel:")
- print("")
- print("Put bottom block on slot 1")
- print("Put chests on slot 14.")
- print("Put torches on slot 15.")
- print("Put coal on slot 16.")
- print("Height:")
- repeat
- term.setCursorPos(9,7)
- print(" ")
- term.setCursorPos(9,7)
- height=tonumber(read())
- until height>0
- term.setCursorPos(1,8)
- print("Width:")
- repeat
- term.setCursorPos(8,8)
- print(" ")
- term.setCursorPos(8,8)
- width=tonumber(read())
- until width>0
- term.setCursorPos(1,9)
- print("Length:")
- repeat
- term.setCursorPos(9,9)
- print(" ")
- term.setCursorPos(9,9)
- length=tonumber(read())
- until length>0
- term.setCursorPos(1,10)
- print("Torch every:")
- repeat
- term.setCursorPos(14,10)
- print(" ")
- term.setCursorPos(14,10)
- torchspc=tonumber(read())
- until torchspc>0
- torchin=torchspc
- blocks=height*width*length
- dug=0
- horzPos=0
- vertPos=0
- torchPos=0
- for iL=1,length do
- goF()
- if width>1 then
- if horzPos==0 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- for iW=1,width do
- dug=dug+1
- status()
- if vertPos==0 then
- place()
- for iH=2,height do
- goU()
- dug=dug+1
- status()
- end
- else
- for iH=2,height do
- goD()
- dug=dug+1
- status()
- end
- place()
- end
- if iW~=width then
- goF()
- end
- vertPos=(vertPos*-1)+1
- end
- if width>1 then
- if horzPos==0 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- horzPos=(horzPos*-1)+1
- torchin=torchin-1
- if torchin==0 then
- if vertPos==1 then
- for i=2,height do
- goD()
- end
- vertPos=0
- end
- if horzPos==0 then
- turtle.turnRight()
- if torchPos==1 then
- for i2=2,width do
- goF()
- end
- horzPos=1
- end
- turtle.turnRight()
- else
- turtle.turnLeft()
- if torchPos==0 then
- for i2=2,width do
- goF()
- end
- horzPos=0
- end
- turtle.turnLeft()
- end
- goF()
- turtle.select(15)
- turtle.placeUp()
- turtle.select(1)
- turtle.turnRight()
- turtle.turnRight()
- goF()
- torchin=torchspc
- torchPos=(torchPos*-1)+1
- end
- if invFull() then
- if vertPos==1 then
- for i2=2,height do
- goD()
- end
- vertPos=0
- end
- if horzPos==1 then
- if width>1 then
- turtle.turnLeft()
- for i2=2,width do
- goF()
- end
- turtle.turnRight()
- horzPos=0
- end
- end
- turtle.turnRight()
- if width==1 then
- goU()
- digF()
- goD()
- end
- local placed=false
- digF()
- turtle.select(14)
- if turtle.place() then
- for i2=2,13 do
- turtle.select(i2)
- turtle.drop()
- end
- turtle.select(1)
- end
- turtle.turnLeft()
- end
- end
- turtle.turnLeft()
- if vertPos==1 then
- goD()
- end
- if horzPos==1 then
- for i=2,width do
- goF()
- end
- end
- turtle.turnLeft()
- for i=1,length do
- goF()
- end
- turtle.turnLeft()
- turtle.turnLeft()
Advertisement
Add Comment
Please, Sign In to add comment