Jump to content




Easy Automatic Tree Farm

turtle

3 replies to this topic

#1 ChallengerC4

  • New Members
  • 2 posts

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 by ChallengerC4, 18 January 2016 - 04:10 AM.


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,464 posts

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 by Lyqyd, 18 January 2016 - 02:18 AM.


#3 NilLogic

  • Members
  • 45 posts

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?

#4 ChallengerC4

  • New Members
  • 2 posts

Posted 18 January 2016 - 08:41 PM

View PostNilLogic, on 18 January 2016 - 04:59 PM, said:

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 by ChallengerC4, 18 January 2016 - 09:10 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users