Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- length = 0
- materialSlot = 1
- allOut = false
- function forward()
- for i=1,20 do
- if turtle.detect() then
- turtle.dig()
- else
- break
- end
- end
- for i=1,20 do
- if not turtle.forward() then
- turtle.dig()
- sleep(2)
- else
- break
- end
- end
- end
- function up()
- digUp()
- turtle.up()
- end
- function down()
- digDown()
- turtle.down()
- end
- function digUp()
- for i=1,20 do
- if turtle.detectUp() then
- turtle.digUp()
- else
- break
- end
- end
- end
- function digDown()
- if turtle.detectDown() then
- turtle.digDown()
- end
- end
- function ensureMaterial()
- if allOut then
- return false
- end
- if turtle.getItemCount(materialSlot) < 3 then
- organizeMaterial()
- end
- if turtle.getItemCount(materialSlot) < 3 then
- print("No more material")
- allOut = true
- return false
- end
- return true
- end
- function organizeMaterial()
- local i
- materialCount = turtle.getItemCount(materialSlot)
- if materialCount < 3 then
- -- print("Attempting to refill slot ", materialSlot)
- for i=2,16 do
- turtle.select(i)
- if turtle.compareTo(materialSlot) then
- turtle.transferTo(materialSlot)
- end
- end
- end
- turtle.select(materialSlot)
- end
- function bore(len)
- for i=1,len do
- forward()
- digUp()
- digDown()
- end
- end
- function boreUpper(len)
- for i=1,len do
- forward()
- digUp()
- digDown()
- placeBlockUp()
- end
- end
- function boreLower(len)
- for i=1,len do
- digDown()
- placeBlockDown()
- forward()
- end
- end
- function placeBlock()
- if ensureMaterial() then
- turtle.select(materialSlot)
- turtle.place()
- end
- end
- function placeBlockUp()
- if ensureMaterial() then
- turtle.select(materialSlot)
- turtle.placeUp()
- end
- end
- function placeBlockDown()
- if ensureMaterial() then
- turtle.select(materialSlot)
- turtle.placeDown()
- end
- end
- function sideWall()
- for i=1,length do
- placeBlockUp()
- placeBlockDown()
- turtle.back()
- placeBlock()
- end
- end
- args = {...}
- nArgs = #args
- if nArgs ~= 1 then
- print("Usage: bore <length>")
- return
- end
- length = tonumber(args[1])
- if length == nil then
- print("\"", args[1], "\" is not a valid length") return
- end
- digUp()
- turtle.up()
- bore(length) -- Right-hand wall
- sideWall()
- turtle.turnLeft()
- forward()
- turtle.turnRight()
- up()
- boreUpper(length)
- turtle.turnLeft()
- turtle.turnLeft()
- down()
- down()
- boreLower(length)
- turtle.turnRight()
- forward()
- turtle.turnRight()
- forward()
- boreLower(length)
- turtle.turnLeft()
- turtle.turnLeft()
- up()
- up()
- boreUpper(length)
- forward()
- turtle.turnRight()
- forward()
- turtle.turnRight()
- boreUpper(length)
- turtle.turnLeft()
- turtle.turnLeft()
- down()
- down()
- boreLower(length)
- turtle.turnRight()
- forward()
- turtle.turnRight()
- up()
- bore(length)
- sideWall()
- --[[
- forward()
- turtle.turnLeft()
- bore(length)
- sideWall()
- --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement