Posted 05 December 2012 - 06:11 AM
Not sure where the issue is here. Hope someone can help. I, along with what appears to be hundreds of others, am working on a tree farm program. In an attempt to be thorough, I want the turtle to check each location and determine what is there in each spot and act accordingly.
My issue is this: The above code works, and works 99% accurately when I load my turtle with the saplings and logs of rubber trees from industrial craft. However the accuracy drops dramatically when the turtle is loaded with birch saplings and logs. When a turtle executes the compare using birch 85% of the comparisons are returned as "I don't know what is here". This happens when the turtle compares to saplings and trees both. I have not tried this with pine, redwood, or jungle trees yet.
My question: Why is "other" being returned when "sapling" or "tree" conditions are true?
P.S. The sleep() calls are there to keep the turtle from doing all of this too fast and returning unwanted results.
-- Examine location and return what is there
function checkLocation()
turtle.turnLeft() -- to look at location
sleep(1)
if turtle.detect() then
sleep(1)
turtle.select(15) -- slot holding saplings
sleep(1)
if turtle.compare() then
print("There is a sapling here already.")
sleep(1)
return ("sapling")
end
sleep(1)
turtle.select(14) -- slot holding at least 1 log block
sleep(1)
if turtle.compare() then
print("There is a tree here already.")
sleep(1)
return ("tree")
end
print("I don't know what is here.")
sleep(1)
return("other")
else -- if nothing dectected
print("This space is available.")
sleep(1)
return ("nothing")
end
end
My issue is this: The above code works, and works 99% accurately when I load my turtle with the saplings and logs of rubber trees from industrial craft. However the accuracy drops dramatically when the turtle is loaded with birch saplings and logs. When a turtle executes the compare using birch 85% of the comparisons are returned as "I don't know what is here". This happens when the turtle compares to saplings and trees both. I have not tried this with pine, redwood, or jungle trees yet.
My question: Why is "other" being returned when "sapling" or "tree" conditions are true?
P.S. The sleep() calls are there to keep the turtle from doing all of this too fast and returning unwanted results.