Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if #tArgs == 1 then
- amount = tonumber( tArgs[1] )
- else
- amount = 1
- end
- if turtle.getItemCount(16) < amount then
- print("Please supply sufficient saplings in bottom right slot.")
- return
- end
- -- -- -- -- functions -- -- -- --
- local function tryDig()
- while turtle.detect() do
- if turtle.dig() then
- sleep(0.1)
- else return false
- end end
- return true
- end
- local function tryForward()
- while not turtle.forward() do
- if turtle.detect() then
- if not tryDig() then
- return false
- end
- elseif turtle.attack() then
- collect()
- else
- sleep( 0.5 )
- end end
- return true
- end
- -- -- -- -- main loop -- -- -- --
- turtle.select(16)
- for i = 1, amount do
- repeat turtle.forward() until turtle.detect()
- tryForward()
- repeat
- turtle.digUp()
- turtle.up()
- until not turtle.detectUp()
- repeat turtle.down()
- until turtle.detectDown()
- turtle.digDown()
- turtle.placeDown()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement