Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This program tells a turtle to cut down a giant spruce tree
- ]]
- --[[ Functions ]]
- local function fellColumn()
- turtle.dig()
- turtle.forward()
- while turtle.detectUp() do
- turtle.digUp()
- turtle.up()
- end
- while not turtle.detectDown() do
- turtle.down()
- end
- end
- local function fwd()
- while not turtle.forward() do
- turtle.dig()
- end
- end
- --[[ Main ]]
- -- Determine that the tree is grown
- local has_block, data = turtle.inspect()
- if data.name ~= "minecraft:spruce_log" then
- print("There's no grown tree in front of me")
- return
- end
- -- Determine if you have enough fuel
- if turtle.getFuelLevel() < 242 then
- print("Please provide at least 242 fuel")
- return
- end
- -- Collect all logs
- fellColumn()
- fellColumn()
- turtle.turnRight()
- fellColumn()
- turtle.turnRight()
- fellColumn()
- -- Drop off logs
- fwd()
- for i = 1, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- -- Get saplings
- turtle.turnRight()
- fwd()
- turtle.turnRight()
- turtle.select(1)
- turtle.suckDown(4)
- -- Plant saplings
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- turtle.place() -- Sapling 1
- turtle.turnLeft()
- turtle.back()
- turtle.place()-- Sapling 2
- turtle.turnLeft()
- turtle.back()
- turtle.place() -- Sapling 3
- turtle.back()
- turtle.place() -- Sapling 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement