Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Minecraft mod 'ComputerCraft' Script
- -- for Automated trees search
- -- Each run requires: nil
- -- Patrol movements
- for i = 1,10 do -- number of turns
- for k = 1,2 do
- for j = 1,i do
- for u = 1,10 do -- there cant be 10 blocks high, right?
- -- what's in front of me?
- local obsFront, dataFront = turtle.inspect()
- if not obsFront then -- If there's nothing in front of me:
- turtle.forward()
- -- I moved forward, what's below of me?
- local obsDown, dataDown = turtle.inspectDown()
- -- If there's nothing below of me:
- if not obsDown then
- for i = 1,10 do -- there cant be a 10 block cliff, please god
- turtle.down()
- -- I moved down, what's below of me?
- local obsDown, dataDown = turtle.inspectDown()
- -- If what I have below are leaves, dig. otherwise end:
- if obsDown then
- if dataDown.name == 'minecraft:leaves' then
- turtle.digDown()
- else
- break
- end
- end
- end
- end
- break
- elseif dataFront.name == 'minecraft:log' then -- If there's a tree in front of me:
- shell.run('choptree') -- I chop the tree and move forward where the tree was
- -- I moved forward, what's below of me?
- local obsDown, dataDown = turtle.inspectDown()
- -- If there's tree below me:
- if dataDown.name == 'minecraft:log' then
- for i = 1,10 do -- there cant be 10 logs below, please god
- turtle.digDown()
- turtle.down()
- -- I moved down, what's below of me?
- local obsDown, dataDown = turtle.inspectDown()
- -- If there are no more logs end:
- if dataDown.name ~= 'minecraft:log' then
- break
- end
- end
- end
- break
- elseif dataFront.name == 'minecraft:leaves' then -- If there are leaves in front of me:
- turtle.dig()
- turtle.forward()
- -- I moved forward, what's below of me?
- local obsDown, dataDown = turtle.inspectDown()
- -- If there's nothing below of me:
- if not obsDown then
- for i = 1,10 do -- there cant be a 10 block cliff, please god
- turtle.down()
- -- I moved down, what's below of me?
- local obsDown, dataDown = turtle.inspectDown()
- -- If what I have below are leaves, dig. otherwise end:
- if obsDown then
- if dataDown.name == 'minecraft:leaves' then
- turtle.digDown()
- else
- break
- end
- end
- end
- end
- break
- else -- If there's something that's not a tree in front of me:
- -- I need to climb that block
- -- Can I go up? What's over me?
- local obsUp, dataUp = turtle.inspectUp()
- -- If there are leaves, dig 'em
- if dataUp.name == 'minecraft:leaves' then
- turtle.digUp()
- turtle.up()
- else -- if not, then just go up
- if not obsUp then -- Only if theres actually air
- turtle.up()
- end
- end
- end
- end
- end
- turtle.turnRight()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement