Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Advanced 2x2 Tree Felling Program
- -- Written by ianJustice
- -- Inspired by SethBling
- -- Tree detection fixed by ArbitraryHubris
- -- Place in front of left side of 2x2 tree
- fuel = 1
- saplings = 2
- bonemeal = 3
- logs = 4
- -- Place fuel in indicated slot
- local function checkFuel()
- if turtle.getFuelLevel() < 1 then
- turtle.select(fuel)
- turtle.refuel(1)
- end
- end
- local function digAndMove()
- turtle.dig()
- turtle.attack()
- checkFuel()
- turtle.forward()
- end
- local function digAndMoveUp()
- turtle.digUp()
- checkFuel()
- turtle.up()
- end
- local function turnAround()
- turtle.turnRight()
- turtle.turnRight()
- end
- local function chopUp()
- digAndMove()
- while turtle.digUp() do
- turtle.dig()
- checkFuel()
- turtle.up()
- end
- turtle.dig()
- checkFuel()
- while turtle.down() do
- checkFuel()
- end
- end
- local function fell()
- chopUp()
- turnAround()
- digAndMove()
- turtle.turnLeft()
- digAndMove()
- turtle.turnLeft()
- chopUp()
- turtle.turnLeft()
- digAndMove()
- turtle.turnLeft()
- digAndMove()
- turnAround()
- end
- local function plant()
- digAndMove()
- digAndMove()
- turtle.turnRight()
- turtle.select(saplings)
- turtle.place()
- turtle.turnRight()
- digAndMove()
- turtle.turnLeft()
- turtle.place()
- turtle.turnLeft()
- turtle.place()
- turnAround()
- digAndMove()
- turnAround()
- turtle.place()
- turtle.select(bonemeal)
- turtle.place()
- turtle.select(saplings)
- seconds = 0
- while turtle.compare() do
- if seconds == 300 then
- turtle.select(bonemeal)
- turtle.place()
- turtle.select(saplings)
- seconds = 0
- end
- seconds = seconds + 1
- os.sleep(1.0)
- end
- end
- local function dropLogs()
- print("Depositing Lumber")
- for i = 5, 16 do
- turtle.select(i)
- if turtle.compareTo(logs) == true then
- turtle.drop()
- end
- end
- end
- local function getCoal()
- if turtle.getItemCount(fuel) < 4 then
- print("Resupplying Coal")
- turtle.select(fuel)
- turtle.suck(16)
- end
- end
- local function getSaplings()
- if turtle.getItemCount(saplings) < 4 then
- print("Resupplying Saplings")
- turtle.select(saplings)
- turtle.suckDown(16)
- end
- end
- local function getBonemeal()
- if turtle.getItemCount(bonemeal) < 4 then
- print("Resupplying Bonemeal")
- turtle.select(bonemeal)
- turtle.suckUp(16)
- end
- end
- while true do
- plant()
- print("Tree successfully planted")
- fell()
- print("Tree successfully felled")
- turtle.turnLeft()
- getCoal()
- turtle.turnLeft()
- dropLogs()
- turnAround()
- getSaplings()
- getBonemeal()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement