Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = { ... }
- local distance = 0
- local dropItems = false
- local makeFloor = false
- local enclosed = false
- local height = 2
- turtle.select(1)
- function select(slot)
- turtle.select(slot)
- end
- function forward()
- while not turtle.forward() do
- turtle.dig()
- end
- end
- function up()
- while not turtle.up() do
- turtle.digUp()
- end
- end
- function down()
- while not turtle.down() do
- turtle.digDown()
- end
- end
- function place(slot)
- select(slot)
- while not turtle.place() do
- turtle.dig()
- end
- end
- function placeUp(slot)
- select(slot)
- while not turtle.placeUp() do
- turtle.digUp()
- end
- end
- function placeDown(slot)
- select(slot)
- while not turtle.placeDown() do
- turtle.digDown()
- end
- end
- function left()
- turtle.turnLeft()
- end
- function right()
- turtle.turnRight()
- end
- function uturn()
- left()
- left()
- end
- function flooring(slot)
- for i = 2, distance do
- turtle.digUp()
- placeDown(slot)
- forward()
- end
- turtle.digUp()
- placeDown(slot)
- end
- function roofingCorner(slot)
- for i = 2, distance do
- placeDown(slot)
- forward()
- end
- placeDown(slot)
- end
- function roofing(slot)
- for i = 2, distance do
- placeUp(slot)
- forward()
- end
- placeUp(slot)
- end
- -- parse command line
- if #args == 0 then
- print("Usage: Tunnel [distance]")
- print("Optional tags:")
- print(" -hx: height of tunnel x (1-3)")
- print(" (default: 2)")
- print(" -d: drop items")
- print(" -f: create floor")
- print(" (put mats in slot 1)")
- print(" -e: enclosed")
- else
- distance = args[1]
- if #args > 1 then
- for i=2, #args do
- if args[i] == "-d" then
- dropItems = true
- elseif args[i] == "-f" then
- turtle.select(1)
- makeFloor = true
- elseif string.sub(args[i], 1, 2) == "-h" then
- height = tonumber(string.sub(args[i], 3, 3))
- elseif args[i] == "-e" then
- enclosed = true
- end
- end
- end
- end
- if enclosed then --do enclosed tunnel
- flooring(14)
- left()
- forward()
- left()
- flooring(13)
- left()
- forward()
- forward()
- left()
- flooring(15)
- up()
- uturn()
- flooring(11)
- right()
- forward()
- forward()
- right()
- flooring(9)
- up()
- uturn()
- flooring(5)
- left()
- forward()
- forward()
- left()
- flooring(7)
- up()
- uturn()
- roofingCorner(3)
- right()
- forward()
- forward()
- right()
- roofingCorner(1)
- right()
- forward()
- right()
- down()
- down()
- roofing(2)
- down()
- uturn()
- else --do regular tunnel
- for i = 1, distance do
- forward()
- if height > 1 then turtle.digUp() end
- if height > 2 then turtle.digDown() end
- if makeFloor then
- placeDown()
- end
- if dropItems then turtle.drop() end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement