Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function forward()
- while turtle.detect() do
- turtle.dig()
- sleep(0.5)
- end
- flag = turtle.forward()
- while not flag do
- turtle.attack()
- sleep(0.5)
- flag = turtle.forward()
- end
- end
- function up()
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0.5)
- end
- flag = turtle.up()
- while not flag do
- turtle.attackUp()
- sleep(0.5)
- flag = turtle.up()
- end
- end
- function down()
- while turtle.detectDown() do
- turtle.digDown()
- sleep(0.5)
- end
- flag = turtle.down()
- while not flag do
- turtle.attackDown()
- sleep(0.5)
- flag = turtle.down()
- end
- end
- function restock() -- Try to refill slots 1 to 15
- local i, j
- for i=1,13,1 do
- turtle.select(i)
- for j=i+1,14,1 do
- if turtle.compareTo(j) then
- turtle.select(j)
- turtle.transferTo(i)
- turtle.select(i)
- end
- end
- end
- end
- function check_front()
- if not turtle.detect() then
- if turtle.getItemCount(2) < 2 then
- restock()
- end
- turtle.select(2)
- turtle.place()
- end
- end
- function check_up()
- if not turtle.detectUp() then
- if turtle.getItemCount(2) < 2 then
- restock()
- end
- turtle.select(2)
- turtle.placeUp()
- end
- end
- function check_down()
- if not turtle.detectDown() then
- if turtle.getItemCount(2) < 2 then
- restock()
- end
- turtle.select(2)
- turtle.placeDown()
- end
- end
- function check()
- turtle.turnLeft()
- check_front()
- turtle.turnRight()
- turtle.turnRight()
- check_front()
- turtle.turnLeft()
- end
- function upAndDown()
- check_down()
- check()
- up()
- check()
- up()
- check()
- check_up()
- forward()
- check_up()
- check()
- down()
- check()
- down()
- check()
- check_down()
- end
- function section()
- local i
- while turtle.getFuelLevel() < 30 do
- turtle.select(1)
- turtle.refuel(1)
- end
- upAndDown()
- forward()
- upAndDown()
- forward()
- turtle.select(15)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- upAndDown()
- forward()
- upAndDown()
- if turtle.getItemCount(13) > 0 then
- restock()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(16)
- turtle.place()
- for i=3,14,1 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- function tunnel(...)
- local args = {...}
- if #args ~= 1 then
- print "Usage: tunnel <length of tunnel>"
- print "- Slot 1: Fuel"
- print "- Slot 2: Wall filler"
- print "- Slot 15: Torches"
- print "- Slot 16: Chests"
- error()
- end
- local i=0
- local tlen=tonumber(args[1])
- while tlen > 0 do
- section()
- tlen = tlen-8
- if tlen > 0 then
- forward()
- end
- i = i+1
- end
- restock()
- turtle.back()
- turtle.select(2)
- turtle.place()
- turtle.up()
- turtle.place()
- turtle.up()
- turtle.place()
- turtle.down()
- turtle.down()
- turtle.turnLeft()
- turtle.turnLeft()
- up()
- i = (i*8)-2
- while i > 0 do
- while turtle.getFuelLevel() < 10 do
- turtle.select(1)
- turtle.refuel(1)
- end
- turtle.forward()
- i = i-1
- end
- turtle.select(16)
- turtle.placeDown()
- for i=1,16,1 do
- turtle.select(i)
- turtle.dropDown()
- end
- end
- tunnel(...)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement