Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TreeKilla v1.1
- -- Usage: treekill
- -- TreeKilla will pull and store the first block
- -- it finds. It then moves into the tree and
- -- begins to chop its way up, harvesting logs
- -- and leaves on the way.
- -- Once TreeKilla no longer finds logs above
- -- itself, it will move back down.
- -- If TreeKilla is set to tear down a 2x2 tree,
- -- it will move to the other corner of the trunk
- -- before coming down.
- local function spindig()
- for i=1,4 do
- turtle.dig()
- turtle.turnLeft()
- end
- end
- local y = 0
- local s = 0
- local f = 0
- local isBig = false
- local treeDir = 0 -- 0 for other log is left, 1 for other log is right
- local fuel
- while turtle.getFuelLevel() <= 400 do
- turtle.select(1) -- Refuel from slot 1
- turtle.refuel(1)
- end
- fuel = turtle.getFuelLevel() -- We'll tell how much fuel we used
- turtle.select(2)
- turtle.dig()
- turtle.forward() -- The turtle is now inside the tree.
- f = f + 1 -- We moved forward one block.
- -- Detect "big" tree - is there a block ahead?
- if turtle.detect() then
- isBig = true
- turtle.turnLeft()
- if turtle.detect() then
- treeDir = 0
- else
- treeDir = 1
- end
- turtle.turnRight()
- spindig()
- else
- spindig() -- We'll always spindig.
- end
- -- Until we encounter air above our tree, go up.
- while turtle.detectUp() ~= false do
- turtle.digUp()
- turtle.up()
- spindig()
- y = y + 1
- end
- if isBig then
- if treeDir == 0 then
- turtle.turnLeft()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- else
- turtle.turnRight()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- spindig()
- turtle.forward()
- spindig()
- -- Descend.
- while y ~= 0 do
- turtle.digDown()
- turtle.down()
- spindig()
- y = y - 1
- end
- else
- while y ~= 0 do
- turtle.down()
- y = y - 1
- end
- end
- if isBig then
- if treeDir == 0 then
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.turnLeft()
- else
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.turnRight()
- end
- else
- turtle.back()
- end
- print("We used " .. fuel - turtle.getFuelLevel() .. " units of fuel")
Advertisement
Add Comment
Please, Sign In to add comment