Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local depth = 50
- local height = 2
- local r = 3
- function _detect(func)
- while turtle.detect() do
- if not func() then break end
- end
- while turtle.attack() do
- end
- end
- function dig()
- _detect(turtle.dig)
- turtle.turnRight()
- _detect(turtle.dig)
- turtle.turnLeft()
- turtle.turnLeft()
- _detect(turtle.dig)
- turtle.turnRight()
- _detect(turtle.digUp)
- _detect(turtle.digDown)
- end
- function fwd(n, flag_dig_all)
- local _fwd = function()
- repeat
- turtle.attack()
- turtle.dig()
- turtle.suck()
- until turtle.forward()
- return true
- end
- for i=1,n do
- if flag_dig_all then dig() end
- _fwd()
- end
- end
- function up(n)
- local _up = function()
- repeat
- turtle.digUp()
- turtle.attackUp()
- turtle.suckUp()
- until turtle.up()
- return true
- end
- for i=1,n do
- _up()
- end
- end
- function down(n)
- local _down = function()
- repeat
- turtle.attackDown()
- turtle.digDown()
- turtle.suckDown()
- until turtle.down()
- for i=1,n do
- _down()
- end
- return true
- end
- function backToHome()
- _detect(turtle.dig)
- repeat
- turtle.dig()
- turtle.attack()
- until turtle.forward()
- return true
- end
- -- main
- fwd(depth, true)
- turtle.turnRight()
- turtle.turnRight()
- down(3)
- fwd(depth, true)
- up(3)
Advertisement
Add Comment
Please, Sign In to add comment