Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pathfind(block)
- if block.name == "minecraft:oak_planks" then -- turn right
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- elseif block.name == "minecraft:spruce_planks" then -- turn left
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- elseif block.name == "minecraft:oak_slab" then -- skip water
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- elseif block.name == "minecraft:spruce_slab" then -- skip water
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- elseif block.name == "minecraft:stone" then -- go home
- goHome()
- end
- end
- function goHome()
- turtle.turnRight()
- turtle.up()
- turtle.up()
- turtle.up()
- home = false
- while not home do
- turtle.forward()
- bool, block = turtle.inspect()
- if bool then
- home = true
- end
- end
- dumpAll()
- turtle.turnRight()
- turtle.down()
- turtle.down()
- turtle.down()
- sleep(60*19) -- minecraft day is 20 minutes
- end
- function dumpAll()
- for i=2,16 do
- turtle.select(i)
- while turtle.getItemCount() > 0 do
- turtle.drop()
- end
- end
- turtle.select(1)
- end
- function makeMove()
- bool, blockForward = turtle.inspect()
- if bool then
- pathfind(blockForward)
- else
- turtle.forward()
- end
- end
- while true do
- bool, blockDown = turtle.inspectDown()
- if not bool then
- turtle.placeDown()
- makeMove()
- elseif blockDown.state.age == 7 then
- turtle.digDown()
- turtle.placeDown()
- makeMove()
- else
- makeMove()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement