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

Turtles not comparing to Sugar Cane

Started by stilldabomb, 05 October 2012 - 12:21 AM
stilldabomb #1
Posted 05 October 2012 - 02:21 AM
ComputerCraft Version Information: 1.41 Client / 1.41 Server

Description of Bug: A turtle won't compare a sugar cane(Item) and a sugar cane(Block)

Steps to Reproduce Bug: do turtle.compare() with sugar cane?
Lyqyd #2
Posted 05 October 2012 - 05:56 AM
That's because they're different things.
robhol #3
Posted 05 October 2012 - 06:13 AM
Yeah, that's helpful.

Would Silk Touch work? The whole .compare() thing is kinda limited, there's a mod with "database turtles" that you can train to recognize a wider range of blocks.
stilldabomb #4
Posted 05 October 2012 - 08:13 AM
That's because they're different things.
Yes, but it's impossible to get a Sugar Cane block without using commands or an inventory editor, so this should be fixed. By when checking items change them to the blocks then comparing (In the mod, not lua).
Cloudy #5
Posted 05 October 2012 - 09:38 AM
That's because they're different things.
Yes, but it's impossible to get a Sugar Cane block without using commands or an inventory editor, so this should be fixed. By when checking items change them to the blocks then comparing (In the mod, not lua).

You can't handle that in all cases. Not without a huge list of what maps to what.

Why do you need to check if a block is a sugarcane? Genuine question - not saying I won't "fix" it, but maybe I can suggest alternatives.
stilldabomb #6
Posted 06 October 2012 - 05:13 AM
That's because they're different things.
Yes, but it's impossible to get a Sugar Cane block without using commands or an inventory editor, so this should be fixed. By when checking items change them to the blocks then comparing (In the mod, not lua).

You can't handle that in all cases. Not without a huge list of what maps to what.

Why do you need to check if a block is a sugarcane? Genuine question - not saying I won't "fix" it, but maybe I can suggest alternatives.
I was on Immibis' server, and I had broken into a house with a sugar cane farm, and I was super bored. So I fixed their Sugar Cane farming turtle. I get that you guys don't have unlimited time, and that you would have to do mapping, but last time I checked, you can get an item for a block with block.getItem() or something. I haven't used MCP in awhile :D/>/>
Cloudy #7
Posted 06 October 2012 - 11:07 AM
That's because they're different things.
Yes, but it's impossible to get a Sugar Cane block without using commands or an inventory editor, so this should be fixed. By when checking items change them to the blocks then comparing (In the mod, not lua).

You can't handle that in all cases. Not without a huge list of what maps to what.

Why do you need to check if a block is a sugarcane? Genuine question - not saying I won't "fix" it, but maybe I can suggest alternatives.
I was on Immibis' server, and I had broken into a house with a sugar cane farm, and I was super bored. So I fixed their Sugar Cane farming turtle. I get that you guys don't have unlimited time, and that you would have to do mapping, but last time I checked, you can get an item for a block with block.getItem() or something. I haven't used MCP in awhile :D/>/>

turtle.detect() would work fine with a sugar came farm. No need for turtle.compare()

And no, it really isn't that simple.
stilldabomb #8
Posted 06 October 2012 - 11:17 AM
And no, it really isn't that simple.
Well, like I've said, I haven't used MCP in awhile.
Zaflis #9
Posted 06 March 2014 - 07:13 PM
This bug is still around in computercraft for 1.6.4. It is impossible to check if block in front of turtle is a sugarcane or not.

Of course there are clumsy workarounds for the problem, but it still exists. Sugarcane is 1 of the basic things one would think of using turtles for. Oddly it works just fine with cactus (although cactus is destroyed when turtle comes next to it, but compareDown works).

Alternative solution would be to let us detect what block ID is in front, up and down, would help alot.
CometWolf #10
Posted 06 March 2014 - 07:30 PM
A cactus drops the actual cactus block, whereas canes drop the item instead of the block, so not really that weird. Item ID detection has been suggested many times before, it's too overpowered.
Bomb Bloke #11
Posted 06 March 2014 - 11:07 PM
Why would a turtle need to know if a block in front of it is sugarcane/reeds/whatever they're called now or not? If you tell it to go harvest around a certain area, is it not enough for it to know that there are blocks in the area you want chopped up?
Engineer #12
Posted 08 March 2014 - 12:00 AM
Why would a turtle need to know if a block in front of it is sugarcane/reeds/whatever they're called now or not? If you tell it to go harvest around a certain area, is it not enough for it to know that there are blocks in the area you want chopped up?
Shouldnt matter, this bug should be not a bug. Because a mechanic is broken it has to be fixed, because someone is going to need it eventually
Zaflis #13
Posted 11 March 2014 - 12:30 AM
Why would a turtle need to know if a block in front of it is sugarcane/reeds/whatever they're called now or not? If you tell it to go harvest around a certain area, is it not enough for it to know that there are blocks in the area you want chopped up?
You can make dynamic scripts with setups like this, imagine sideview:
CT||||||W
-|||||||W
-|||||||W
Where C=Chest, T=Turtle, |=Sugarcane, W=Wall
It would move forward until the turtle.forward() command returns false, as it meets a wall. But it would only dig sugarcanes which it could detect with turtle.compare(). Otherwise it would break through the wall, unless it's Thaumcraft warded or something. And with this setup it gets more complicated if i were to compare both ends for chest and wall, and having both of them in inventory for the same ID.

But i made a workaround for this, having the turtle move between 2 wall blocks instead, and have chest above, because it can compare wall blocks and not dig them. Basically i don't need to tell it that the area size is some constant like 16, it can just move as long as it can and i can expand the farm later if i want to, without modifying the code at all.

Later i realized that my new script would have worked with the old setup aswell, because i am no longer doing any turn commands for turtle. Once it meets the wall, it will move backwards until it can't. So it only actually compares the other wall. This is more reliable for server restart cases, because it can't ever be in wrong position or orientation, when startup auto-activates it. Also it is unlikely that sugar would grow 2 blocks behind it in time it takes for it to go forth and back. Because turtle can just ram through sugarcane without digging, and the turtle.back() will only fail when it meets a chest or wall.
edit: Oops, no the old setup still wouldn't work because it would have to turn to reach the chest. Only feasible place for chest is above.
Edited on 10 March 2014 - 11:42 PM