This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ChallengerC4's profile picture

Easy Automatic Tree Farm

Started by ChallengerC4, 18 January 2016 - 12:34 AM
ChallengerC4 #1
Posted 18 January 2016 - 01:34 AM
So I created this program to automatically farm birch or pine trees.
It is a rather simple program, but I feel that it could be of use to beginners who want to start understanding code.
I provide a pretty thorough documentation of the program with my youtube video, which shows the program in application,
and explains the code in a step-by-step manner.


Here is the link: https://youtu.be/wpq5XyjWWM0

I hope you learn a bit from my work.

Thank you!! :D/>


--[[Version 1.0]]--
function fuelCheck()
  local fuelLevel = turtle.getFuelLevel()
  if fuelLevel < 20 then
    turtle.select(1)
    turtle.refuel(1)
    print("Refueled!")
  end
end

function chopTree()
  local success, data = turtle.inspect()
  if data.name == "minecraft:log" then
    print("Tree detected... chopping.")
    turtle.dig()
    turtle.forward()
    while turtle.detectUp() == true do
      turtle.digUp()
      turtle.up()
    end
    while turtle.detectDown() == false do
      turtle.down()
    end
    turtle.back()
    turtle.select(3)
    turtle.place()
    turtle.select(1)
  end
end

local chopping = true
while chopping do
  fuelCheck()
  chopTree()
  turtle.suck()
  turtle.suckUp()
end


Edited on 18 January 2016 - 03:10 AM
Lyqyd #2
Posted 18 January 2016 - 01:37 AM
No code to show, locked. Please report your topic when you are ready to post code so we can re-open it for you.

Re-opened so code may be posted.
Edited on 18 January 2016 - 01:18 AM
NilLogic #3
Posted 18 January 2016 - 04:59 PM
Nice work! although I have some questions; question 1: What if slot 1 does not have a valid fuel source? (e.g nothing, or saplings), question 2: What is the point in turtle.suck() in your while true do loop? (turtle.dig() does this), question 3: Why does the fourms not let me scroll up to look at the rest of your code while replying and force me to type as slow as a turtle to print a character?
ChallengerC4 #4
Posted 18 January 2016 - 08:41 PM
Nice work! although I have some questions; question 1: What if slot 1 does not have a valid fuel source? (e.g nothing, or saplings), question 2: What is the point in turtle.suck() in your while true do loop? (turtle.dig() does this), question 3: Why does the fourms not let me scroll up to look at the rest of your code while replying and force me to type as slow as a turtle to print a character?

Ok, so there isn't really a trouble shooting technique that the turtle follows besides fuelcheck(), but it doesn't use a huge amount of energy (about 14 per tree), Coal tends to last long enough for me, and I can refuel using the trees I get. Also, the suck just takes the saplings as they fall. It tends to gain enough of a return to make the process nearly infinite.

Edit: Ok so the math works out to be this: 1 Tree on average is 6 blocks of wood and 1 TreeChop requires on average 14 fuel. 6 blocks yields 400 fuel taking account for the 1 coal used to make the charcoal, meaning your fuel profit is about 386 per tree chopped. This could easily sustain a self refueling system, but would need a second turtle to A. Take the birch B. Store Some C. Make birch into charcoal, and D. give the "chopper" more fuel.

Sounds like a project I'll have to get into.
Edited on 18 January 2016 - 08:10 PM