Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local treeGrow = false
- local tArgs = {...}
- function plant()
- print("Planting Saplings!")
- if turtle.compareDown(turtle.select(15)) then --Chest/Block the turtle starts on
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.select(1) --Sapling
- turtle.place()
- turtle.turnRight()
- turtle.back()
- turtle.place()
- turtle.turnLeft()
- turtle.place()
- turtle.turnRight()
- turtle.back()
- turtle.place()
- end
- print("Planting Complete!")
- end
- function grow()
- print("Growing Plants!")
- for i = 1,5 do
- turtle.select(2) -- Bonemeal
- turtle.place()
- end
- if turtle.compare(turtle.select(1)) then --Sapling
- noTreeGrowth()
- else
- treeGrow = true
- end
- end
- function fell()
- print("Felling The Tree!")
- turtle.dig()
- turtle.forward()
- while turtle.detect() or turtle.detectUp() do
- turtle.digUp()
- turtle.dig()
- turtle.up()
- end
- turtle.turnRight()
- turtle.back()
- turtle.turnLeft()
- while not turtle.compareDown(turtle.select(16)) and turtle.detectDown() or turtle.detect() do --Dirt
- turtle.digDown()
- turtle.down()
- turtle.dig()
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.back()
- treeGrow = false
- end
- function noTreeGrowth()
- print("Growth Attempt Failed!")
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- turtle.dig()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- turtle.dig()
- turtle.turnRight()
- turtle.back()
- turtle.back()
- treeGrow = false
- end
- function plantNGrow()
- plant()
- grow()
- end
- function dropItems() --Selects slots 3-14 and deposits them in the chest
- print("Dropping Items in slots 3-12...")
- n = 3
- for i = 1,12 do
- turtle.select(n)
- turtle.dropDown()
- n = n + 1
- end
- print("Done Dropping...")
- end
- function refuel()
- print("Refueling...")
- turtle.select(3)
- turtle.refuel()
- turtle.select(4)
- turtle.refuel()
- end
- print("Plant, Grow, Fell, Drop, Loop, Refuel or Stop?")
- input = read()
- if input == "Plant" or input == "plant" or tArgs[1] == "Plant" or tArgs[1] == "plant" then
- plant()
- end
- if input == "Grow" or input == "grow" or tArgs[1] == "Grow" or tArgs[1] == "grow" then
- grow()
- end
- if input == "Fell" or input == "fell" or tArgs[1] == "plant" or tArgs[1] == "fell" then
- fell()
- end
- if input == "Drop" or input == "drop" or tArgs[1] == "Drop" or tArgs[1] == "drop" then
- dropItems()
- end
- if input == "Refuel" or input == "refuel" then
- refuel()
- end
- if input == "Stop" or input == "stop" then
- print("Stopping...")
- sleep(1)
- shell.run("reboot")
- end
- while input == "Loop" or input == "loop" or tArgs[1] == "Loop" or tArgs[1] == "loop" do
- if turtle.detect() then
- if turtle.compare(turtle.select(1)) then --Sapling
- grow()
- end
- else
- plantNGrow()
- while treeGrow == false do
- plantNGrow()
- end
- if treeGrow == true then
- fell()
- if turtle.getFuelLevel() <= 200 then
- refuel()
- end
- dropItems()
- end
- end
- if turtle.getItemCount(1) <= 4 then --If Sapling amount is <= 4
- print("Need more Saplings!")
- write("Continue?")
- answer = read()
- if answer == "y" or answer == "yes" then
- print("Continuing...")
- sleep(1)
- shell.run(shell.getRunningProgram(), "loop")
- end
- if answer == "n" or answer == "no" then
- print("Stopping...")
- sleep(1)
- shell.run("reboot")
- end
- end
- if turtle.getItemCount(2) <= 5 then --If Bonemeal ammount is <= 5
- print("Need more Bonemeal!")
- write("Continue?")
- answerB = read()
- if answerB == "y" or answerB == "yes" then
- print("Continuing...")
- sleep(1)
- end
- if answerB == "n" or answerB == "no" then
- print("Stopping...")
- sleep(1)
- shell.shutdown()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement