Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- get arguments
- local tArgs = { ... }
- if #tArgs ~= 1 then
- print( "Usage: basicTunne; <Tunnel Length>" )
- return
- end
- local tunnelLength = tonumber( tArgs[1] )
- if tunnelLength < 1 then
- print( "Tunnel Length must be positive!" )
- return
- end
- -- function to tunnel 1x3 directly in front
- local function digInFront ()
- if turtle.detectUp() then
- if turtle.digUp() then
- turtle.suckDown()
- end
- end
- if turtle.detect() then
- if turtle.dig() then
- turtle.suckDown()
- end
- end
- if turtle.detectDown() then
- if turtle.digDown() then
- turtle.suckDown()
- end
- end
- end
- -- function to move x blocks in given direction (left / right) maintaining orientation
- local function move(numToMove, orientation)
- local cleanNumToMove = tonumber( numToMove )
- if orientation == "left" then
- if turtle.turnLeft() then
- for i = 0, cleanNumToMove, 1 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- end
- if orientation == "right" then
- if turtle.turnRight() then
- for i = 0, cleanNumToMove, 1 do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- end
- end
- -- program start
- local done = false
- while not done do
- for n = 0, tunnelLength/2 do
- digInFront()
- move(1, "right")
- digInFront()
- move(1, "right")
- digInFront()
- turtle.forward()
- digInFront()
- move(1, "left")
- digInFront()
- move(1, "left")
- digInFront()
- end
- done = true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement