Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Program to cut a 1x1 tree.
- -- ExCreationS V1
- --[[place the turtle at the base of the tree.
- Place a chest behind the turtle.
- Bonemeal placed in slot 14,
- saplings placed in slot 15,
- fuel placed in slot 16.]]
- -- Function for refueling
- function checkFuel()
- if turtle.getFuelLevel() <= 10 then
- if turtle.getItemCount(16) == 0 then
- print("Out of fuel.")
- exit()
- else
- turtle.select(16)
- turtle.refuel(1)
- turtle.select(1)
- end --if
- end --if
- end --checkFuel()
- -- Create the function to turn around
- function turnAround()
- turtle.turnRight()
- turtle.turnRight()
- end --turnAround()
- -- Function to deposit wood
- function dropOff()
- for slot = 1,13 do
- turtle.select(slot)
- turtle.drop()
- end --for
- end --dropOff()
- -- Function to plant the sapling
- function plant()
- if turtle.getItemCount(15) >= 1 then
- turtle.select(15)
- turtle.place()
- turtle.select(1)
- else
- print("Not enough saplings.")
- exit()
- end --if
- end --plant()
- -- Function to bonemeal new tree
- function bonemeal()
- if turtle.getItemCount(14) >= 1 then
- turtle.select(15)
- while turtle.compare() do
- turtle.select(14)
- turtle.place()
- turtle.select(15)
- end --while
- turtle.select(1)
- else
- print("Not enough bonemeal.")
- exit()
- end --if
- end --bonemeal()
- -- Function to chop the tree
- function chopTree()
- turtle.dig()
- turtle.forward()
- while turtle.detectUp() do
- checkFuel()
- turtle.digUp()
- turtle.up()
- end --while
- while not turtle.detectDown() do
- turtle.down()
- end --while
- turtle.back()
- end --chopTree()
- -- Main script
- print("")
- print(" [Tree Feller]")
- print(" Press enter to exit the program")
- print(" -----------------")
- print("")
- repeat
- print("How many trees should be felled:")
- local countTo = read()
- if tonumber(countTo) == nil or tonumber(countTo) == 0 then
- countTo = 0
- print(countTo, " tree(s) have been felled!")
- print("Goodbye...")
- sleep(2)
- break
- elseif tonumber(countTo) < 0 then
- print("That won't work..")
- else --if tonumber(countTo) > 0 then
- for index = 1, countTo do
- checkFuel()
- print("Chopping the tree...")
- chopTree()
- print("Depositing items...")
- turnAround()
- dropOff()
- turnAround()
- print("Planting new sapling...")
- plant()
- print("Using bonemeal...")
- bonemeal()
- end --for
- print(countTo, " tree(s) have been felled!")
- end --if
- until tonumber(countTo) > 0
Advertisement
Add Comment
Please, Sign In to add comment