Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cutDownTree()
- print("Cutting down tree")
- s, d = turtle.inspect()
- while s do
- turtle.dig()
- turtle.digUp()
- turtle.up()
- s, d = turtle.inspect()
- end
- print("Going down")
- s, d = turtle.inspectDown()
- while not s do
- turtle.down()
- s, d = turtle.inspectDown()
- end
- print("Tree down")
- end
- function getAroundTree()
- print("Getting around tree")
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- function tryForward()
- -- Try to go forward
- if not turtle.forward() then
- s, d = turtle.inspect()
- if d.name == "ic2:rubber_wood" then
- cutDownTree()
- return true
- elseif d.name == "ic2:sapling" then
- getAroundTree()
- return true
- else
- print("Can not go forward")
- return false -- return false if stuck
- end
- -- return false if not line
- s, d = turtle.inspectDown()
- if d.name ~= "minecraft:stone_slab" then
- print("Line lost")
- turtle.back()
- return false
- end
- return true
- end
- function followLine()
- while true do
- if not tryForward() then
- turtle.turnRight()
- if not tryForward() then
- turtle.turnLeft()
- turtle.turnLeft()
- if not tryForward() then
- print("Stuck")
- return
- end
- end
- end
- end
- end
- followLine()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement