Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = "minecraft:"
- function stuck()
- while not turtle.forward() do
- if turtle.detect() then
- turtle.dig()
- else
- sleep(1)
- end
- end
- end
- function turnR()
- turtle.turnRight()
- stuck()
- turtle.turnRight()
- turtle.digDown()
- end
- function turnL()
- turtle.turnLeft()
- stuck()
- turtle.turnLeft()
- turtle.digDown()
- end
- function torch()
- local tcnt = 0
- for i = 1,16 do
- local blk = turtle.getItemDetail(i)
- if blk and
- blk.name == m.."torch" then
- tcnt = tcnt + blk.count
- else
- i = i + 1
- end
- end
- return tcnt
- end
- ----------
- local arg = {...}
- local dir = tostring(arg[1])
- local pass = 1
- local l = 1
- turtle.digDown()
- while turtle.forward() do
- turtle.digDown()
- l = l + 1
- end
- while not turtle.forward() do
- local y,blk = turtle.inspect()
- if blk.name == m.."torch" then
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- l = l + 1
- print("Length: "..l)
- --? start on left or right
- if dir == "l" then
- turnR()
- else
- turnL()
- end
- pass = pass + 1
- while torch() ~= 2 do
- for i = 1,l do
- if i == l then
- turtle.digDown()
- elseif i == l-1
- and pass%2 == 1 then
- local s,data = turtle.inspect()
- if s and
- data.name == m.."torch" then
- turtle.digDown()
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- return
- else
- turtle.digDown()
- turtle.dig()
- turtle.forward()
- end
- else
- turtle.digDown()
- stuck()
- end
- end
- if dir == "l" then
- if pass%2 == 0 then
- turnL()
- pass = pass + 1
- else
- turnR()
- pass = pass + 1
- end
- else
- if pass%2 == 0 then
- turnR()
- pass = pass + 1
- else
- turnL()
- pass = pass + 1
- end
- end
- end
- else
- turtle.dig()
- turtle.forward()
- l = l + 1
- turtle.digDown()
- end
- end
- if pass%2 == 0 then
- for j = 1,l-1 do
- if j == l-1 then
- turtle.digDown()
- else
- turtle.digDown()
- stuck()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement