←  Turtle Programs

ComputerCraft | Programmable Computers for Minecraft

»

AutoTreeFarm Program V2

Anonomit's Photo Anonomit 12 Aug 2012

EDIT: New, far superior program can be found here: http://bit.ly/Q6zqCt

Credit for original code to BikerEleven

EDIT: BikerEleven has stopped playing minecraft, and has given me permission to take credit for any updates.

Original forum thread can be found here:
http://bit.ly/NYbb3u

This is an update for BikerEleven's [1.3]AutoTreeFarm program

Here are a few of the changes:
Spoiler


You got my attention, so what do I do?
Spoiler

How do I install these programs?
Spoiler

Where can I get these programs?
Spoiler

What about the bonus programs that will make tree farming so much easier? I must have them!
Spoiler

Edit:

--Code Updated!

Spoiler
Quote

Bushido's Photo Bushido 08 Sep 2012

Can u add when it is full it returns to empty it's inventory and to refill it's saplings some how? other wise it is awesome bro
Quote

Anonomit's Photo Anonomit 14 Sep 2012

if you're using tekkit, set up an advanced wooden transport pipe to suck out only the wood.
make sure the turtle is set to 'output redstone on cycle'. press 's' to recreate settings.
as for refilling saplings, the problem is that if i were to add that in, the turtle would need to be refilled before EVERY trip, manually or with pipes.
maybe i'll release an update that gives an option to refill saplings.
for now though, the saplings will need to be refilled manually, sorry :)/>

Edit:
--if updating, press 's' to recreate settings, otherwise you will get an error.
--turtle now has an option to wait for full saplings between cycles.
--the turtle will output redstone on the bottom, left and right sides.
--make the redstone power a redstone engine, powering a pipe that brings saplings to the turtle.
--depending on how long the pipe is, the turtle will have to throw away a couple saplings if he gets too many.
--use a transposer to automatically pick up any extra saplings.
--turtle will not wait for full saplings unless 'output redstone on cycle' is selected.

--this code is not ideal, but it works if you really want that small amount more automation.
--if not, do not select 'Wait for full saplings'
Quote

hi_tech_guy_18's Photo hi_tech_guy_18 21 Sep 2012

You need to add a refuel command at the begging so it self refuels pref from the last slot
Quote

Bushido's Photo Bushido 23 Sep 2012

Computer craft keeps spitting out this http://pastebin.com/RmQSrPG8. The turtle will place saplings and cycle redstone signal and stop when saplings are full but it will stop while trying to harvest the trees.



Edit: Fixed the chat error spam Nocheat doesn't like mining turtles.
Quote

Xanafrim's Photo Xanafrim 27 Sep 2012

I JUST started trying out Computer Craft and I found this program. I have installed it and it was working fine but then I fixed the ground a bit where it dropped a level. After I did this I hit "r" and he went on another round. However, ever since then he only takes 2 logs per tree and leaves the rest for me to clean up. I did not alter any of the code so I am no sure what might have happened.

Possibly it is connected to lag as that is an issue for me. I run a single core processor right now, no hyperthreading, 2 GB ram. That's the max this laptop can hold. However, I also am the admin of a paid server that runs tekkit and that is the only place I play. The server does have 1 GB of ram. I am running the current Tekkit pack.

Thanks for any help on this.
Quote

Bushido's Photo Bushido 27 Sep 2012

At least yours gets some logs all mine does is run into the tree and stop lol.
Quote

Anonomit's Photo Anonomit 27 Sep 2012

View PostXanafrim, on 27 September 2012 - 04:42 AM, said:

I JUST started trying out Computer Craft and I found this program. I have installed it and it was working fine but then I fixed the ground a bit where it dropped a level. After I did this I hit "r" and he went on another round. However, ever since then he only takes 2 logs per tree and leaves the rest for me to clean up. I did not alter any of the code so I am no sure what might have happened.

Possibly it is connected to lag as that is an issue for me. I run a single core processor right now, no hyperthreading, 2 GB ram. That's the max this laptop can hold. However, I also am the admin of a paid server that runs tekkit and that is the only place I play. The server does have 1 GB of ram. I am running the current Tekkit pack.

Thanks for any help on this.

That's strange. Is it possible that you accidentally moved the turtle to a different starting location? The turtle should harvest up a tree until the block above him is not wood. If he stops harvesting early, maybe there is lag, which could be making him check the block too soon. It's a theory. Could you try it out on single player and let me know if there's still a problem?
Quote

Anonomit's Photo Anonomit 27 Sep 2012

View PostBushido, on 27 September 2012 - 06:35 AM, said:

At least yours gets some logs all mine does is run into the tree and stop lol.

Hi Bushido, it sounds like your turtle is eaither not a mining turtle or doesn't have permission to break the tree blocks. If this is on a server, check with the server admin to make sure that the area isn't protected from players of minimum rank. perhaps he can OP the fakeplayer [ComputerCraft]?
Quote

Bushido's Photo Bushido 28 Sep 2012

well im the admin of the server and it is a mining turtle so the only answer left is that the protection zone i have in place is preventing it from mining it thank you i feel stupid that i didn't think of that
Quote

Anonomit's Photo Anonomit 28 Sep 2012

If you're using worldguard, try using the command:
/rg addowner regionname [ComputerCraft]

If that doesn't work, try checking the turtle config file, and make sure the fakeplayer login is enabled. This thread explains why that's important: http://bit.ly/QJqXBF

EDIT: I forgot, it depends what your config setting is for fakeplayer whether you can op all turtles at once or have to allow permissions to each one separately
Quote

Cranium's Photo Cranium 28 Sep 2012

If using residence, the command would be /res pset plotname [computercraft]turtleid flag true
Quote

Lost Ninja's Photo Lost Ninja 16 Oct 2012

Is it possible to have this work prior to getting going with wireless systems?

I tried just using the logger program on it's own but it just chops anything placed above it but does nothing else (and no helpful error messages either).

I don't want/need all the other wireless functionality. Just a turtle that farms trees. :/ (No criticism intended.) (And I'm too lazy/thick to write my own.)
Quote

slay_mithos's Photo slay_mithos 21 Oct 2012

It is quite a nice script, even without wireless and all, but looking at the code, I found some strange things, like using only 9 slots and wasting 2 units of fuel per tree when cutting.

I wanted to know if you would mind that I change bits to accommodate with my own usage, or if I need to create a blank project for it.

To be honest, I just want a turtle to farm the trees, replant them, and deposit the wood, take some fuel if needed, then wait for 5-10 minutes and go again, with the startup script launching it, and this seems to be working well enough to save me part of the work.

No hard feeling if you decline, or find me rude.
Quote

Anonomit's Photo Anonomit 24 Oct 2012

View PostLost Ninja, on 16 October 2012 - 09:14 AM, said:

Is it possible to have this work prior to getting going with wireless systems?

I tried just using the logger program on it's own but it just chops anything placed above it but does nothing else (and no helpful error messages either).

I don't want/need all the other wireless functionality. Just a turtle that farms trees. :/ (No criticism intended.) (And I'm too lazy/thick to write my own.)

This program is not updated for turtles that require fuel, sorry. It's intended of CC 1.3 (for tekkit use). It sound like that may be the problem you're experiencing.

View Postslay_mithos, on 21 October 2012 - 09:02 PM, said:

It is quite a nice script, even without wireless and all, but looking at the code, I found some strange things, like using only 9 slots and wasting 2 units of fuel per tree when cutting.

I wanted to know if you would mind that I change bits to accommodate with my own usage, or if I need to create a blank project for it.

To be honest, I just want a turtle to farm the trees, replant them, and deposit the wood, take some fuel if needed, then wait for 5-10 minutes and go again, with the startup script launching it, and this seems to be working well enough to save me part of the work.

No hard feeling if you decline, or find me rude.

By all means, edit away! Feel free to post any improvements if you'd like. I may end up making one from scratch eventually to weed out the bugs that have cropped up recently.
Quote

slay_mithos's Photo slay_mithos 25 Oct 2012

I made two changes to the program:

The first being I changed the harvestTree a bit to prevent the down() dig() forward() up() that wasted 2 fuel for each tree, replaced by a simple dig() forward() digDown(), and changed step to 3 for the rest to continue working as expected
    local function harvestTree()
		   
		    steps = 3
            turtle.select(3)
            if turtle.detect() then
						    turtle.dig()
				    end
				    while not turtle.forward() do
						    turtle.dig()
				    end
            
            turtle.digDown()
            turtle.select(3)
            tryMove( "up" )
            
		    while turtle.compareUp() do
           		 tryMove( "up" )
				    steps = steps + 1
                    if steps == 20 then
                   		 break
                    end
		    end
		    turtle.select(1)
		    while steps > 2 do
                    turtle.select(1)
				    tryMove( "down" )
                    turtle.select(1)
				    steps = steps - 1
		    end
            if outOfSaplings == 0 then
                    plantTree()
            end
     
    end

For my personnal use, I removed the while true at the end and replaced it with my standard "drop items and refuel" to make it loop every 5 minutes, but that is because of my personnal preferences, so I won't be imposing this on anyone, seing as your program, when used with rednet, is way more robust in its handling.
Quote

ChunLing's Photo ChunLing 26 Oct 2012

How about if the turtle spun around and dug in the various directions to try and catch some saplings (or errant logs from oak trees)?
Quote

Anonomit's Photo Anonomit 26 Oct 2012

I started work on a 1.4.1 version that makes use of the relatively newer APIs. I've previously wanted to keep this program compatible with 1.3, as this is the version Tekkit is running. When I get around to finishing, the turtle will be a lot smarter, and worry about fuel consumption. The 1.4.5 update added the transferTo() function in the turtle API, which will be extremely useful for sucking in saplings and not clogging up item spaces, but I'll see if I can make this work without it first. Maybe I'll have it check the running OS to determine what it can call, but if somebody's using a custom OS I would have to assume it isn't updated any farther than 1.3. Or I could ask the user to input the OS version if it's a custom one. I'll see how it turns out.
Quote

Taiine's Photo Taiine 27 Oct 2012

Hello! I've been using this and am enjoying it very much and plan to include it in my soon to be tekkit playthough. However I ran into an issue.

The turtles are supose to stop sending out a redstone signal when all but the first two invatory slots are empty. However mine continue to send out a signal even when I remove everything from them.

I'm using redstone engines with advanced wooden pips to pull the items out, it works great as as soon and the turtle lands it powers the engines however it doesn't stop... leading to a few exploshions Is this a bug, or something I am doing wrong?
Quote

Anonomit's Photo Anonomit 29 Oct 2012

If I recall, the version right now (I guess I should start numbering them) has a couple options that may be the problem. Try pressing the 's' key to recreate the settings. If you have 'wait for full saplings' turned on, the turtle will continue outputting redstone until slot 1 is full of saplings. I personally don't recommend this option, but it does allow a degree more automation in cunjunction with buildcraft. Unless you're pumping saplings into the turtle, or plan to manually refill him every cycle, I suggest you leave that particular option turned off. The 'output redstone on cycle' option however, should, of course, remain turned on. Btw, what exploded? Anyway, let me know if this was the problem, and if it wasn't, re-post with your CC version and as much information on how to reproduce this and I'll see if I can figure out what's up.
Quote