Posted 02 May 2013 - 03:23 PM
It took me a couple of hours to track this bug down in my code. This is for a tree farmer. The first two lines of this code were failing:
Slot 2 has a sample sapling. What it's supposed to do is detect if the block is a sapling. If so, fertilize it, then harvest the tree. Normally this works fine, but I found that once out of four times or so it plows right through the sapling without attempting to fertilize it. I checked this part of my code over and over and all was fine.
But I just now thought to partially-fertilize the sapling and then compare. Sure enough, it fails. A partially-fertilized sapling block does not match the sapling item. I imagine a partially-grown tree fails, too (which is normally the case for my failures).
I will rewrite this chunk of code to test the negative case instead (compare a block of wood, slot 1), but I wondered if there's another way to compare saplings or if this is a bug or whatever.
turtle.select(2)
if turtle.compare() then
fertilize()
chop()
replant()
else
moveThruTree()
end
moveToNextTree()
Slot 2 has a sample sapling. What it's supposed to do is detect if the block is a sapling. If so, fertilize it, then harvest the tree. Normally this works fine, but I found that once out of four times or so it plows right through the sapling without attempting to fertilize it. I checked this part of my code over and over and all was fine.
But I just now thought to partially-fertilize the sapling and then compare. Sure enough, it fails. A partially-fertilized sapling block does not match the sapling item. I imagine a partially-grown tree fails, too (which is normally the case for my failures).
I will rewrite this chunk of code to test the negative case instead (compare a block of wood, slot 1), but I wondered if there's another way to compare saplings or if this is a bug or whatever.