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

Tree farming help

Started by Radsail, 13 April 2013 - 10:51 PM
Radsail #1
Posted 14 April 2013 - 12:51 AM
Hi I want help please with my tree farm.I want my turtle to suck the saplings,coal and bonemeal out of an chest.Here is my program


local function checkFuel()
  if turtle.getFuelLevel() < 1 then
	turtle.select(1)
	turtle.refuel(1)
  end
end
local function column()
  while turtle.digUp() do
	turtle.dig()
	checkFuel()
	turtle.up()
  end
  turtle.dig()
  checkFuel()
  while turtle.down() do
	checkFuel()
  end
end
local function digmove()
  checkFuel()
  turtle.dig()
  turtle.forward()
end
local function plant()
  turtle.select(2)
  turtle.forward(1)
  turtle.place()
  turtle.turnRight()
  turtle.forward(1)
  turtle.turnLeft()
  turtle.place()
  turtle.turnRight()
  turtle.turnRight()
  turtle.forward(1)
  turtle.turnRight()
  turtle.turnRight()
  turtle.place()
  turtle.turnLeft()
  turtle.forward(1)
  turtle.turnRight()
  turtle.place()
end
local function dropwood()
  for i=3, 16 do
  turtle.select( i)
  turtle.dropDown()
  end
  turtle.select(3)
  end
while true do --Always loop
  dropwood()
  plant()
  turtle.up()
  local Wait, Correct = "0", "1"
while Wait~=Correct do
   if turtle.detect()==true then
Wait = "1"
  print("success")
end
sleep(5)
  end
turtle.down()
digmove()
column()
turtle.turnRight()
digmove()
turtle.turnLeft()
column()
turtle.turnLeft()
digmove()
digmove()
turtle.turnRight()
column()
turtle.turnRight()
turtle.forward(1)
turtle.turnRight()
turtle.forward(1)
turtle.turnRight()
turtle.turnRight()

end

Thanx alot
P.S sorry for posting this 2 times on the site becuase I didnt know in the begin where to post this so Thanx
Lyqyd #2
Posted 14 April 2013 - 01:05 AM
You haven't really provided enough detail. Sure, you want it to suck those items out of a chest or chests, but you haven't given any specifics on in what part of the program you want those operations performed, or where the chests are located, etc.
Radsail #3
Posted 14 April 2013 - 01:13 AM
Ok
After it drops the wood.


local function checkFuel()
  if turtle.getFuelLevel() < 1 then
		turtle.select(1)
		turtle.refuel(1)
  end
end
local function column()
  while turtle.digUp() do
		turtle.dig()
		checkFuel()
		turtle.up()
  end
  turtle.dig()
  checkFuel()
  while turtle.down() do
		checkFuel()
  end
end
local function digmove()
  checkFuel()
  turtle.dig()
  turtle.forward()
end
local function plant()
  turtle.select(2)
  turtle.forward(1)
  turtle.place()
  turtle.turnRight()
  turtle.forward(1)
  turtle.turnLeft()
  turtle.place()
  turtle.turnRight()
  turtle.turnRight()
  turtle.forward(1)
  turtle.turnRight()
  turtle.turnRight()
  turtle.place()
  turtle.turnLeft()
  turtle.forward(1)
  turtle.turnRight()
  turtle.place()
end
local function dropwood()
  for i=3, 16 do
  turtle.select( i)
  turtle.dropDown()
  end
  turtle.select(3)
  end
while true do --Always loop
  dropwood()
------------------------Here-------------------------
  plant()
  turtle.up()
  local Wait, Correct = "0", "1"
while Wait~=Correct do
   if turtle.detect()==true then
Wait = "1"
  print("success")
end
sleep(5)
  end
turtle.down()
digmove()
column()
turtle.turnRight()
digmove()
turtle.turnLeft()
column()
turtle.turnLeft()
digmove()
digmove()
turtle.turnRight()
column()
turtle.turnRight()
turtle.forward(1)
turtle.turnRight()
turtle.forward(1)
turtle.turnRight()
turtle.turnRight()
end

It drops the wood at the place where I placed it in the begin so I want to put a chest at the back to give it the saplingsbut should I make an diffrent chest for the bonemeal and coal

Tell me if you need more info
The_Awe35 #4
Posted 14 April 2013 - 10:08 AM
Yes you should make a different chest. turtle.suck() will suck out the first stack in a inventory(like chests, furnaces, etc.), and will place it in the first open slot, or fill up another slot with the same object. turtle.drop(positive integer will drop the amount you selected (all if no number). It will drop it into an inventory if one is in front of it, else it will place it on the ground.
You can either get it to suck out everything, and figure out what is what and how much of each is needed (just keep at least one of what you need in the top slots and compare and drop what you don't want). This can be a bit confusing, and if you have a lot in either the chest or the turtle, it probably won't work. I suggest you have a separate chest on the sides for it.
eg. top - coal
left - sapings
right - bonemeal
i'm assuming you will have full stacks of each in the chests, so to make it clean and not have left over in the turtle, do something like this


local function refill()
turtle.turnLeft() -- for saplings
turtle.select(1)
turtle.drop()
turtle.suck()

turtle.turnRight() -- original position
turtle.turnRight() -- for bonemeal
turtle.select(2)
turtle.drop()
turtle.suck()

turtle.turnLeft() -- original position
turtle.select(3) -- for charcoal
turtle.dropUp()
turtle.suckUp()

--extra for geting rid of wood
  for i = 4,16 do
  turtle.select(i)
  turtle.dropDown()
  end
end

hope this helps