Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- tunnelbuilder <distance>
- -- needs building material in the first slot (eg. cobblestone)
- -- more building material can be supplied in other slots too if needed
- -- turtle will build the top row (with ceiling) first, then turn around, drop below and build the floor
- -- tunnel height will be 2 +1 ceiling +1 floor
- local WALL_SLOT = 1
- local args = { ... }
- local distance = 0
- if #args ~= 1 then
- print("Usage: tunnelbuilder <distance>")
- error()
- end
- distance = args[1]
- if turtle.getFuelLevel() < 2*distance then
- print("Not enough fuel to build the specified distance")
- error()
- end
- -- ---------------------------------------------------------------------
- function reorderWalls()
- for i = 1,16 do
- if i~=WALL_SLOT then
- turtle.select(i)
- os.sleep(0.1)
- if turtle.compareTo(WALL_SLOT) and (turtle.getItemCount(i)>0) then
- while (turtle.getItemCount(i)>0) and (turtle.getItemCount(WALL_SLOT)<64) and (turtle.transferTo(WALL_SLOT,1)) do
- -- os.sleep(0.01)
- end
- end
- end
- end
- turtle.select(WALL_SLOT)
- end
- function suckAll()
- local i = 1
- while i < 17 and (i==WALL_SLOT or turtle.getItemSpace(i)==0) do
- i = i + 1
- end
- turtle.select(i)
- turtle.suck()
- turtle.suckUp()
- turtle.suckDown()
- reorderWalls()
- turtle.select(WALL_SLOT)
- end
- function wall()
- turtle.select(WALL_SLOT)
- while turtle.detect() and not turtle.compare() do
- turtle.dig()
- suckAll()
- end
- turtle.select(WALL_SLOT)
- if not turtle.compare() then
- turtle.place()
- end
- end
- function wallUp()
- turtle.select(WALL_SLOT)
- while turtle.detectUp() and not turtle.compareUp() do
- turtle.digUp()
- suckAll()
- end
- turtle.select(WALL_SLOT)
- if not turtle.compareUp() then
- turtle.placeUp()
- end
- end
- function wallDown()
- turtle.select(WALL_SLOT)
- while turtle.detectDown() and not turtle.compareDown() do
- turtle.digDown()
- suckAll()
- end
- turtle.select(WALL_SLOT)
- if not turtle.compareDown() then
- turtle.placeDown()
- end
- end
- -- ---------------------------------------------------------------------
- reorderWalls()
- for i=1,distance do
- while not turtle.forward() do
- turtle.dig()
- end
- turtle.turnLeft()
- wall()
- turtle.turnRight()
- turtle.turnRight()
- wall()
- turtle.turnLeft()
- wallUp()
- end
- -- turn around and drop
- turtle.turnRight()
- turtle.turnRight()
- while not turtle.down() do
- turtle.digDown()
- suckAll()
- end
- for i=1,distance-1 do
- while not turtle.forward() do
- turtle.dig()
- end
- turtle.turnLeft()
- wall()
- turtle.turnRight()
- turtle.turnRight()
- wall()
- turtle.turnLeft()
- wallDown()
- end
Advertisement
Add Comment
Please, Sign In to add comment