Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Written by AaronDM
- --Autonomously plants, grows, harvests, and deposits any 2x2 tree
- --Run program, follow directions, input how many runs you would like to perform.
- --To see where to place chest, run once and note where turtle stops to dump items.
- --Basic fuel check function
- function checkFuel()
- if turtle.getFuelLevel() < 100 then
- repeat
- turtle.select(16)
- turtle.refuel(2)
- turtle.select(1)
- until turtle.getFuelLevel() >= 100
- end --if
- end --checkFuel()
- --Plants 4 Redwood saplings in a 2x2
- function plantTree()
- turtle.select(14)
- turtle.forward()
- turtle.place()
- turtle.back()
- turtle.place()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.place()
- turtle.back()
- turtle.place()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end --plantTree()
- --Applies bonemeal and checks if tree has grown. If not, sleeps and repeats.
- function growTree()
- turtle.select(15)
- turtle.place()
- turtle.up()
- if turtle.forward() == true then
- repeat
- turtle.back()
- turtle.down()
- sleep(120)
- turtle.place()
- turtle.up()
- until turtle.forward() == false
- end --if
- turtle.down()
- end --growTree()
- --Cuts down the Redwood. Up the left side, then down the right side.
- function cutTree()
- turtle.dig()
- sleep(0.25)
- turtle.forward()
- turtle.dig()
- local height = 0
- if turtle.detectUp() == true then
- repeat
- turtle.dig()
- turtle.digUp()
- turtle.up()
- height = height + 1
- until turtle.detectUp() == false
- end --if
- checkFuel()
- turtle.turnRight()
- if turtle.detect() == true then
- turtle.dig()
- end --if
- turtle.forward()
- turtle.turnLeft()
- if turtle.detectDown() == true then
- repeat
- turtle.dig()
- turtle.digDown()
- turtle.down()
- height = height - 1
- until height == 0
- end --if
- turtle.dig()
- end --cutTree()
- --Deposits the first 7 slots in a chest behind the turtle.
- function dropOff()
- checkFuel()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.select(1)
- turtle.drop()
- turtle.select(2)
- turtle.drop()
- turtle.select(3)
- turtle.drop()
- turtle.select(4)
- turtle.drop()
- turtle.select(5)
- turtle.drop()
- turtle.select(6)
- turtle.drop()
- turtle.select(7)
- turtle.drop()
- turtle.select(1)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- checkFuel()
- end --dropOff()
- --Attempts to light leftover leaves on fire, then returns to original position.
- function burnTree()
- if turtle.detectUp() == false then
- repeat
- turtle.up()
- until turtle.detectUp() == true
- end
- turtle.down()
- turtle.select(13)
- turtle.placeUp()
- if turtle.detectDown() == false then
- repeat
- turtle.down()
- until turtle.detectDown() == true
- end
- turtle.select(1)
- end --burnTree()
- function checkInventory()
- return turtle.getItemCount(13) >= 1 and turtle.getItemCount(14) >= 4 and turtle.getItemCount(15) >= 2 and turtle.getItemCount(16) >= 2
- end --checkInventory()
- --Main Script
- term.clear()
- print("Please confirm inventory.")
- print("Slot 13 = Flint and tender")
- print("Slot 14 = Saplings")
- print("Slot 15 = Bonemeal")
- print("Slot 16 = Fuel")
- print("Run how many times?")
- times=tonumber(read())
- for i=1,times do
- checkFuel()
- cutTree()
- checkFuel()
- dropOff()
- burnTree()
- sleep(400)
- end
Advertisement
Add Comment
Please, Sign In to add comment