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

Rebootable Turtle Arboretum Replacement and RP2 Automated Flax Farmer

Started by abculatter_2, 28 December 2012 - 11:03 PM
abculatter_2 #1
Posted 29 December 2012 - 12:03 AM
Yup, that's right, I made a turtle which can completely replace an arboretum, in a far more efficient way, for 100% non-Sengir-approved OPness. :P/>

First off, I HIGHLY reccomend you fence in your turtle, like I did, just in case you don't set things up correctly, or if you find a bug. This also does not require any tools, all you need is a regular turtle.

Those who are interested in knowing more about how it works can go ahead and look at the code, and you can copy it to your heart's content. I will try to answer any questions, and fix any bugs, but don't be surprised if I don't visit this thread very often.

Now, as for how to use it,
First set up a 21x21 platform, like so:
Spoiler
(Note that, while the pillars are not necessary, they do add some nice aesthetics, in my opinion. :P/>)

Next, place another layer of cobble on top of the first one, but offset inward by one, with an at least 3-wide expansion of the original layer like I have shown in the picture, minus the gap: (This, while not absolutely necessary, will allow you to maximize tree planting area, while still collecting more or less 100% of the saplings.)
Spoiler

Next, place dirt on top of the platform with an overhang, so that it's a 21x21 square, but without a block underneath the edges. Then put water source blocks along the edges, so that they flow toward the center and beneath the overhang, but be careful that you put them at LEAST two blocks apart from each other at the corners.
Spoiler

Now, place the marker blocks. The fencing is optional, and you have some leeway in what blocks you can use, but you MUST set things up like this EXACTLY!
Some notes: I used oak wood planks to represent slot 2, jungle wood for slot 3, sand for slot 4, bricks for slot 5, and cobble for blocks in which material does not matter. Also, the thing with a dot on it is a charging station from Misc Peripherals. Sorry, but I'm not reprogramming this to work with charcoal, but anyone else who wishes to feel free.
EDIT: Also, the chest on the left is where you should pipe your saplings, while the chest on the right is where the turtle will place excess saplings.
Spoiler


Next is setting up charging station power generation, (I used windmills, but you can use any EU generation you wish. You could even hook this up to be self-sustaining, if you wish.) as well as turtle set-up;
Some notes: The only set-in-stone slots are the torches (you can use any light source, including glowstone and probably RP2's lamps), chests, and saplings, though the saplings don't HAVE to be filled up all the way. The other blocks can be modified as you wish, but it's important that you adjust your set-up accordingly.
Spoiler

And now, for the final steps of set-up, just place down your chosen light sources in whatever pattern you wish (the turtle will not care, and it should be noted that this is not the most efficient pattern)
Spoiler

And then, find the exact center of the dirt platform; start counting from one edge of it, up until you reach 11, and mark that location off with a block. Then do the same on the next side, and then just go straight into the middle with points until they intersect, and place your logger embedded into the above platform there.
Spoiler

Now just power your logger, set up some automated systems for use of the wood, and plop this program into your turtle's startup script, and you're good to go!

Pastebin:
http://pastebin.com/1FqrbwmY

Spoiler

--[[
Feel free to modify this comment.
7 = saplings
1 = torches
2 = oak planks
3 = birch planks
4 = soul sand
5 = cobblestone
6 = chest
]]--
emptySpaces = 0
spins = 0
while true do
recognised = false
continue = true
saplings = 7

turtle.select(saplings)
if not turtle.detectDown() and continue then
  print("I've detected air")
  recognised = true
  emptySpaces = emptySpaces + 1
  print(emptySpaces.." empty spaces so far")
  if emptySpaces > 30 then
   error()
  end
  if turtle.getItemCount(saplings) == 0 and saplings < 10 then
   saplings = saplings + 1
   turtle.select(saplings)
  end
  turtle.placeDown()
  turtle.forward()
  continue = false
end
turtle.select(1)
if turtle.compareDown() and continue then
  print("I've detected a light")
  emptySpaces = 0
  turtle.forward()
  continue = false
end
turtle.select(2)
if turtle.compareDown() and continue then
  print("I've detected slot 2")
  recognised = true
  emptySpaces = 0
  turtle.turnRight()
  turtle.forward()
  continue = false
end
turtle.select(3)
if turtle.compareDown() and continue then
  print("I've detected slot 3")
  recognised = true
  emptySpaces = 0
  turtle.turnLeft()
  turtle.forward()
  continue = false
end
turtle.select(4)
if turtle.compareDown() and continue then
  print("I've detected slot 4")
  recognised = true
  emptySpaces = 0
  while turtle.detect() do
   turtle.turnLeft()
  end
  turtle.forward()
  continue = false
end
turtle.select(5)
if turtle.compareDown() and continue then
  print("I've detected detected slot 5")
  recognised = true
  emptySpaces = 0
  while turtle.detect() do
   turtle.turnLeft()
  end
  for i = 1, 22 do
   turtle.forward()
  end
  continue = false
end
turtle.select(6)
if turtle.compare() then
  print("I've detected a chest")
  spins = 0
  turtle.select(5)
  while not turtle.compare() and spins <= 4 do
   turtle.turnLeft()
   spins = spins + 1
  end
  if spins > 4 then
   print("I don't know what that is.")
   error()
  end
  turtle.turnRight()
  for i = 7, 16 do
   turtle.select(i)
   turtle.suck()
  end
  turtle.turnRight()
  for i = 11, 16 do
   turtle.select(i)
   turtle.drop()
  end
  turtle.turnRight()
  while turtle.getFuelLevel() < 2000 do
   sleep(10)
   print ("Fuel level is "..turtle.getFuelLevel())
  end
  turtle.forward()
end

if not recognised and continue then
  print("I've detected something I don't recognise, I'll assume it's a sapling.")
  turtle.forward()
end
end

For the flax farm, things up like this:
Notes: the planks can be any block, but make sure that your chests are on the slot 13 block's side.
Spoilerhttp://i140.photobuc...zpsc13cb0df.png
http://i140.photobuc...zps219588d1.png

And set up the turtle's inventory like so:
Spoilerhttp://i140.photobuc...zpsaf53ea31.png

Now, just occasionally place charcoal into the top chest, and empty the other chest of string and flax seeds, and you're good to go!
(You can also, obviously, automate this process as well)

Also, you can make this farm as large as you want, as long as the turtle will visit the charcoal chest in less blocks then the fuel value of a bit more then a stack of charcoal, and the farm is a rectangle with the marker blocks in the correct places, you should be good.

And for the code: (Note: this code was done a lot more lazily then the other one, so expect things to not really be the most efficient)

Pastebin:
http://pastebin.com/EanaP50x

Spoiler

--[[
1-4 - flax seeds
5-11 - string
12 - cobble
13 - planks
14 - other planks
15 - chest
16 - charcoal
]]--
seedSlot = 1
coalSlot = 13
while true do
outOfSeeds = 0
refuel = 1
while turtle.getFuelLevel() <= 500 do
  turtle.select(16)
  drop = turtle.getItemCount(16)
  drop = drop - 1
  turtle.refuel(drop)
  refuel = refuel + 1
  if refuel >= 5 then
   print("I am out of fuel")
   error()
  end
end
if turtle.detectDown()then
  turtle.select(seedSlot)
  while turtle.getItemCount(seedSlot) <= 1 do
   seedSlot = seedSlot + 1
   if seedSlot > 4 then
	seedSlot = 1
   end
   turtle.select(seedSlot)
   outOfSeeds = outOfSeeds + 1
   if outOfSeeds >= 6 then
	print("I am out of seeds")
	error()
   end
  end
  turtle.digDown()
  turtle.down()
  turtle.digDown()
  turtle.suckDown()
  turtle.placeDown()
  turtle.up()
  turtle.forward()
end
turtle.select(14)
if turtle.compare() then
  turtle.turnLeft()
  if not turtle.detect() then
   turtle.forward()
  end
  turtle.turnLeft()
end
turtle.select(13)
if turtle.compare() then
  turtle.turnRight()
  if turtle.detect() then
   turtle.turnLeft()
   turtle.turnLeft()
   while not turtle.detect() do
	turtle.forward()
   end
   turtle.turnLeft()
  else
   turtle.forward()
   turtle.turnRight()
  end
end
turtle.select(15)
if turtle.compare() then
  for slot = 5, 12 do
   turtle.select(slot)
   drop = turtle.getItemCount(slot)
   drop = drop - 1
   turtle.drop(drop)
  end
  for slot = 3, 4 do
   turtle.select(slot)
   drop = turtle.getItemCount(slot)
   drop = drop - 1
   turtle.drop(drop)
  end
  turtle.select(16)
  if turtle.getItemCount(16) <= 1 then
   turtle.suckUp()
  end
  turtle.turnRight()
  turtle.forward()
  turtle.turnRight()
end
turtle.select(12)
if turtle.compare() then
  turtle.turnLeft()
end
if not turtle.detectDown() then
  turtle.forward()
end

end
abculatter_2 #2
Posted 29 December 2012 - 12:37 PM
Added pastebins for both programs.
Wizy #3
Posted 30 December 2012 - 11:53 PM
Got a question , i have set up a cobblestone cube the size of logger range with engines logger and chest for saplings in middle sticking out , currently just manually placing saplings ,

So for the question , is it possible to modify this program to work on my setup ( i would be ok with having to manually fill the sapplings and energy to turtle ) , im new to CC so dont fully know the language yet.
abculatter_2 #4
Posted 31 December 2012 - 05:42 AM
Got a question , i have set up a cobblestone cube the size of logger range with engines logger and chest for saplings in middle sticking out , currently just manually placing saplings ,

So for the question , is it possible to modify this program to work on my setup ( i would be ok with having to manually fill the sapplings and energy to turtle ) , im new to CC so dont fully know the language yet.

As long as you put the marker blocks in the right positions, this should work perfectly fine for that as-is.
Wizy #5
Posted 31 December 2012 - 08:10 AM
how do i fix that when he bumps into leaf or wood he stands for some time and stops the program
abculatter_2 #6
Posted 31 December 2012 - 08:49 AM
how do i fix that when he bumps into leaf or wood he stands for some time and stops the program

Placing torches adjacent to all tree trunks will fix that if you're using birch or spruce trees. (which I recommend)

Otherwise… I would say remove the 30 air block check, and make sure there's a fence to prevent the turtle from going AWOL.

EDIT: Quick fix for you, this should work with low-leafing trees, but as I said, be more careful that this one does not go outside of its bounds.

Spoiler
--[[
Feel free to modify this comment.
7 = saplings
1 = torches
2 = oak planks
3 = birch planks
4 = soul sand
5 = cobblestone
6 = chest
]]--
emptySpaces = 0
spins = 0
while true do
recognised = false
continue = true
saplings = 7

turtle.select(saplings)
if not turtle.detectDown() and continue then
  print("I've detected air")
  recognised = true
  if turtle.getItemCount(saplings) == 0 and saplings < 10 then
   saplings = saplings + 1
   turtle.select(saplings)
  end
  turtle.placeDown()
  turtle.forward()
  continue = false
end
turtle.select(1)
if turtle.compareDown() and continue then
  print("I've detected a light")
  emptySpaces = 0
  turtle.forward()
  continue = false
end
turtle.select(2)
if turtle.compareDown() and continue then
  print("I've detected slot 2")
  recognised = true
  emptySpaces = 0
  turtle.turnRight()
  turtle.forward()
  continue = false
end
turtle.select(3)
if turtle.compareDown() and continue then
  print("I've detected slot 3")
  recognised = true
  emptySpaces = 0
  turtle.turnLeft()
  turtle.forward()
  continue = false
end
turtle.select(4)
if turtle.compareDown() and continue then
  print("I've detected slot 4")
  recognised = true
  emptySpaces = 0
  while turtle.detect() do
   turtle.turnLeft()
  end
  turtle.forward()
  continue = false
end
turtle.select(5)
if turtle.compareDown() and continue then
  print("I've detected detected slot 5")
  recognised = true
  emptySpaces = 0
  while turtle.detect() do
   turtle.turnLeft()
  end
  for i = 1, 22 do
   turtle.forward()
  end
  continue = false
end
turtle.select(6)
if turtle.compare() then
  print("I've detected a chest")
  spins = 0
  turtle.select(5)
  while not turtle.compare() and spins <= 4 do
   turtle.turnLeft()
   spins = spins + 1
  end
  if spins > 4 then
   print("I don't know what that is.")
   error()
  end
  turtle.turnRight()
  for i = 7, 16 do
   turtle.select(i)
   turtle.suck()
  end
  turtle.turnRight()
  for i = 11, 16 do
   turtle.select(i)
   turtle.drop()
  end
  turtle.turnRight()
  while turtle.getFuelLevel() < 2000 do
   sleep(10)
   print ("Fuel level is "..turtle.getFuelLevel())
  end
  turtle.forward()
end

if not recognised and continue then
  print("I've detected something I don't recognise, I'll assume it's a sapling.")
  turtle.forward()
end
end
Wizy #7
Posted 31 December 2012 - 09:04 AM
Ok, from short testing it appears to be working , ( it even fixed my other problem with pipes going to ceiling which i had covered with boundaries block).

I just made a circle with type 2(cobblestone ) and type 3(gravel) boundaries blocks so when it reaches end he just turns , he never in theory should go outside bounds ( at first i tried to make the boundaries block out of dirt but it turns to grass :/ ).

Thanks for the help ,Im pretty ok with programming just a bit hard to learn new language when i got tons of finals .
abculatter_2 #8
Posted 31 December 2012 - 09:41 AM
In theory, that should work perfectly. :P/>

And good to hear it's working, hope you do well on those finals!
Wizy #9
Posted 31 December 2012 - 10:40 AM
It still has some fixing to do (ill fix them myself, you already helped a lot) , but atleast it is automated , and plants on most of the field .The problems still appears maybe because of how i set boundaries , also it seems to only get saplings of 2 slots , but i know how to fix this i think.
As for energy consumption it seems to drain very low power , i think stack of coal would be enough for a looong time.

As i dont get enough charcoal from 1 field , ill set the second one the way you intended it to be . Probably ill try to make a program to automate the field making as much as possible.
abculatter_2 #10
Posted 31 December 2012 - 05:25 PM
Could you take some screenshots of your set-up? I'll try looking over the code again for any other error()'s that might be causing you trouble… (Honestly, I just removed 3 or 4 lines of code, but there may be another part of the check somewhere that I had forgotten about.) (Edit: I don't see anything…)
Wizy #11
Posted 31 December 2012 - 09:22 PM
At this point its working fine ( well it sometimes gets stuck but that just shows where my boundaries are wrong,not really a code problem ) , I also edited the slots it checks for saplings , allows me to fill rest of the slots with saplings and dont need refilling that much.
tiromaior #12
Posted 22 September 2013 - 03:21 AM
Sadly, you can't get loggers anymore in newest Forestry Version :(/>
johnneijzen #13
Posted 22 September 2013 - 04:05 AM
Sadly, you can't get loggers anymore in newest Forestry Version :(/>

Use Mine Factory Reloaded logger aka Harvesters