Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = { ... }
- numArgs = table.getn(args)
- TORCH_INTERVAL = 5
- function fuel ()
- if turtle.getFuelLevel() == 0 then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- function plantTunnelTorch ()
- turtle.select(2)
- turtle.placeDown()
- end
- function goodDig ()
- while turtle.detect() do
- fuel()
- turtle.dig()
- sleep(0.5)
- end
- fuel()
- end
- function goodDigUp ()
- while turtle.detectUp() do
- fuel()
- turtle.digUp()
- sleep(0.5)
- end
- fuel()
- end
- function threeByThree ()
- goodDigUp()
- turtle.digDown()
- fuel()
- turtle.turnLeft()
- goodDig()
- turtle.forward()
- goodDigUp()
- turtle.digDown()
- fuel()
- turtle.back()
- fuel()
- turtle.turnRight()
- fuel()
- turtle.turnRight()
- goodDig()
- turtle.forward()
- fuel()
- goodDigUp()
- turtle.digDown()
- fuel()
- turtle.back()
- fuel()
- turtle.turnLeft()
- end
- function twoByTwo()
- goodDigUp()
- turtle.digDown()
- fuel()
- turtle.turnRight()
- goodDig()
- turtle.forward()
- fuel()
- goodDigUp()
- turtle.digDown()
- fuel()
- turtle.back()
- fuel()
- turtle.turnLeft()
- end
- function tunnel (len)
- count = 0
- torch = TORCH_INTERVAL
- while count < len do
- threeByThree()
- --Stairs
- fuel()
- turtle.up()
- threeByThree()
- turtle.up()
- threeByThree()
- turtle.down()
- --EndStairs
- if torch == TORCH_INTERVAL then
- plantTunnelTorch()
- torch = 0
- end
- goodDig()
- turtle.forward()
- fuel()
- count = count+1
- torch = torch+1
- end
- end
- function leftOrRight (dire)
- threeByThree()
- goodDig()
- turtle.forward()
- threeByThree()
- turtle.back()
- fuel()
- if dire == 'l' then
- turtle.turnLeft()
- elseif dire == 'r' then
- turtle.turnRight()
- else
- term.write("Error, bad direction.")
- end
- end
- --================Main===============--
- if numArgs == 1.0 then
- digNum = tonumber(args[1])
- tunnel(digNum)
- elseif numArgs == 2.0 or numArgs == 3.0 then
- if numArgs == 3.0 then
- intervalWidth = tonumber(args[3])
- else
- intervalWidth = TORCH_INTERVAL
- end
- digNum = tonumber(args[1])
- direction = args[2]
- if direction ~= 'r' and direction ~= 'l' then
- error("Second argument must be 'r' or 'l'")
- end
- tunnel(digNum)
- leftOrRight(direction)
- tunnel(intervalWidth)
- leftOrRight(direction)
- tunnel(digNum)
- else
- error("Usage: dig [int] opt[l | r]")
- end
Advertisement
Add Comment
Please, Sign In to add comment