Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- test = true
- orientation = 0
- depth = 0
- turtle.refuel()
- function isInteresting()
- interesting = false
- if turtle.detect() then
- common = false
- for i=1,6 do -- cobble,stone,dirt,sandstone,sand,gravel
- turtle.select(i)
- common = common or turtle.compare()
- end
- interesting = not common
- end
- if interesting then print("There is something interesting.") end
- return interesting
- end
- function isInterestingDown()
- interesting = false
- if turtle.detectDown() then
- common = false
- for i=1,6 do -- cobble,stone,dirt,sandstone,sand,gravel
- turtle.select(i)
- common = common or turtle.compareDown()
- end
- interesting = not common
- end
- if interesting then print("There is something interesting below.") end
- return interesting
- end
- function isInterestingUp()
- interesting = false
- if turtle.detectUp() then
- common = false
- for i=1,6 do -- cobble,stone,dirt,sandstone,sand,gravel
- turtle.select(i)
- common = common or turtle.compareUp()
- end
- interesting = not common
- end
- if interesting then print("There is something interesting above.") end
- return interesting
- end
- function carefulDescent()
- fall = false
- blocked = turtle.detectDown()
- if blocked then turtle.digDown() end
- descent = turtle.down()
- if descent then depth = depth + 1 end
- if not turtle.detectDown() then fall = true end
- if fall then print("Fall below.") end
- return not fall and descent
- end
- function carefulAdvance()
- fall = false
- while turtle.detect() do turtle.dig() end
- advance = turtle.forward()
- if not turtle.detectDown() then fall = true end
- if fall then print("Fall ahead.") end
- return not fall and advance
- end
- function goBack()
- success = false
- while orientation > 0 do
- turtle.turnLeft()
- orientation = orientation - 1
- end
- while depth > 0 do
- repeat
- retreat = turtle.back()
- until not retreat
- success = turtle.up()
- depth = depth - 1
- end
- repeat
- retreat = turtle.back()
- until not retreat
- return success
- end
- while turtle.getFuelLevel() > (depth * 4) do
- warning = false
- c=1
- while c<4 do
- warning = isInterestingUp()
- warning = isInterestingDown()
- while turtle.detectUp() do turtle.digUp() end
- if not warning then carefulAdvance() else break end
- for d=1,4 do
- if not warning then
- turtle.turnRight()
- orientation = (orientation + 1) % 4
- warning = isInteresting()
- else
- break
- end
- end
- c = c+1
- end
- if not warning then turtle.back() end
- if not warning then warning = not carefulDescent() end
- if warning then break end
- end
- goBack()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement