Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin.com/nNgb6mcy
- local WAIT_TIME = 5 -- time to wait to check if tree has grown
- local SAPLING_SLOT = 16
- local FUEL_SLOT = 1
- local DUMP_INTO_CHEST = true
- local WAITING_MESSAGE = "Waiting for tree to grow..."
- term.clear()
- term.setCursorPos(1,1)
- print(WAITING_MESSAGE)
- function fuelCheck()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel < 80 then
- turtle.select(FUEL_SLOT)
- turtle.refuel(1)
- print("Refueled!")
- end
- end
- function chopUp()
- turtle.digUp()
- turtle.dig()
- turtle.up()
- turtle.dig()
- end
- function chopDown()
- turtle.digDown()
- turtle.dig()
- turtle.down()
- end
- function changeSide()
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- end
- function plantSaplings()
- turtle.select(SAPLING_SLOT)
- turtle.place()
- turtle.turnLeft()
- turtle.back()
- turtle.place()
- turtle.turnRight()
- turtle.place()
- turtle.back()
- turtle.place()
- end
- function dump()
- print("Dumping in chest below!")
- for i = 2, 15 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(SAPLING_SLOT)
- end
- function checkTree()
- local success, data = turtle.inspect()
- if success and data.tags["minecraft:logs"] == true then
- print("Tree has grown!")
- fuelCheck()
- chopTree()
- else
- os.sleep(WAIT_TIME)
- end
- end
- function chopTree()
- turtle.select(SAPLING_SLOT)
- turtle.dig()
- turtle.forward()
- local success, dataUp = turtle.inspectUp()
- if not success then
- turtle.back()
- error("\n****\nNo Tree to fell!\n****\n")
- end
- while dataUp.tags["minecraft:logs"] == true do
- chopUp()
- success, dataUp = turtle.inspectUp()
- if not success then
- chopUp()
- break
- end
- end
- chopUp()
- changeSide()
- chopUp()
- while turtle.detectDown() == false do
- turtle.down()
- end
- local success, dataDown = turtle.inspectDown()
- if not success then
- error()
- end
- while dataDown.tags["minecraft:logs"] == true do
- chopDown()
- success, dataDown = turtle.inspectDown()
- if not success then
- break
- end
- end
- turtle.dig()
- plantSaplings()
- if DUMP_INTO_CHEST == true then
- dump()
- print("Dumped items!")
- end
- print(WAITING_MESSAGE)
- end
- while true do
- checkTree()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement