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

This overly complicated tree program will not work please help.

Started by chardo440, 29 December 2012 - 07:15 PM
chardo440 #1
Posted 29 December 2012 - 08:15 PM
http://pastebin.com/sVRr4wrj



All info is in that pastebin. Thanks for the help guys.
Luanub #2
Posted 29 December 2012 - 08:23 PM
I think your problem is because s3() does not return anything.

Try changing it to this:

function s3()
turtle.select(3)
if turtle.compare() then
  return true
else
  return false
end
end
chardo440 #3
Posted 29 December 2012 - 08:38 PM
I think your problem is because s3() does not return anything.

Try changing it to this:

function s3()
turtle.select(3)
if turtle.compare() then
  return true
else
  return false
end
end


Thank you so much! I have just one more question if you have the time. In my code I'm trying to get it to detect if there is a bad item in the way and if there is delete and try running sap() again to go through however when I do this it deletes the item places the sapling grows the tree and backs away from the tree. would I have to fix this with a while true statement somewhere? http://pastebin.com/J85kmAWJ here's my new code with your fix :)/>
Luanub #4
Posted 29 December 2012 - 09:04 PM
It is because with the way you have it setup its only going to run the if statement twice meaning that it never runs harvest() so it never takes the step forward.

I also noticed a problem with you logger function, and you did not setup the down function to bring the turtle back down after the went up. Fixes with comments below
Spoiler

function s3()
turtle.select(3)
if turtle.compare() then
  return true
else
  return false
end
end
 
function sap()
turtle.select(1)
while not s3() do --get everything setup for harvest
  if turtle.compare() == true then
    turtle.select(2)
    turtle.place()
  else
    turtle.dig()
    turtle.select(1)
    turtle.place()
  end
end
harvest() --now harvest
end
 
function logger()
for i=1, 7 do
turtle.up()
turtle.digUp() --he was not digging so he could not go up
end
end
 
function harvest()
turtle.dig()
turtle.forward()
logger()
end
 
function cutter()
sap()
for x=1, 7 do -- here you had simply down() which is not a valid function I put in a loop change it if you want
  turtle.down()
end
turtle.back()
end
 
cutter()