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

[1.42] Sideways logs compare false to logs

Started by GopherAtl, 26 September 2012 - 10:02 PM
GopherAtl #1
Posted 27 September 2012 - 12:02 AM
Discovered this while writing a treecutter program, when they encounter sideways logs, compare returns false when comparing to a log in their inventory from the same tree. :P/>/>
Xfel #2
Posted 27 September 2012 - 06:49 AM
Well, that's oviously because cc only compares with the would-be metadata for placed blocks. of course the metatdata of the sideways logs is different. I wouldn't know how to make it better though. maybe just trash compare
Starwaster #3
Posted 05 October 2012 - 06:27 PM
Well, that's oviously because cc only compares with the would-be metadata for placed blocks. of course the metatdata of the sideways logs is different. I wouldn't know how to make it better though. maybe just trash compare

A special case needs to be made in the compare function for wood blocks. Wood block metadata is used for both type AND facing. From the wiki on wood blocks:

Ok, table not pasting in properly :(/>/>
http://www.minecraftwiki.net/wiki/Birch#Texture_data_values

So if you're comparing a block in the world with ID 17, you would do metadata%4 and THEN compare it to the metadata of what the turtle has in inventory. There's other blockIDs where compare needs to be more robust, and instances where compare() should return truth when certain itemIDs in inventory are compared to blockIDs in the world. (sugarcane, redstone wire/dust, etc etc)
Starwaster #4
Posted 05 October 2012 - 06:29 PM
accidental mis-post, gotta figure out how to delete this. Feeling a bit feverish ATM
Doyle3694 #5
Posted 05 October 2012 - 06:45 PM
well fi you need special case for wood, then you'll have special case for water? and lava? and sugarcane? and wheat? it's not to make one exception. either make 0 or you make 100. and that's a huge waste of time really.
Pyrodogg #6
Posted 05 October 2012 - 07:19 PM
Make zero special cases in CC itself and just expose the IDs and meta information to the user and let them write every special case they care about.
Starwaster #7
Posted 05 October 2012 - 07:21 PM
I guess it
well fi you need special case for wood, then you'll have special case for water? and lava? and sugarcane? and wheat? it's not to make one exception. either make 0 or you make 100. and that's a huge waste of time really.

Well I guess it's all how you look at it. As a programmer, I'd find it a waste of time having a function that doesn't behave consistently or as advertised. I'd either excise such code from my software or I'd fix it.

I think your figure of '100' is overstated as well at worst it's no more than half that, and not all of those may necessarily NEED a case in the function. In fact it might be better to have cases for only a few IDs and then ONLY compare metadata for those few and ignore it for the rest.
Starwaster #8
Posted 05 October 2012 - 07:22 PM
Make zero special cases in CC itself and just expose the IDs and meta information to the user and let them write every special case they care about.

I agree, but the developers have said that will not happen. It's a design decision. I guess they modelled these guys (turtles) after the old LOGO turtles which were fairly dumb and they want to keep it that way.
BrolofTheViking #9
Posted 09 October 2012 - 10:03 PM
I noticed this as well, but since it's technically not a glitch, I posted about it in the suggestions forum.
I believe that it should be changed, and that in the very least trees, but also just generally any situation where the item that exists on the ground can or would have a different ID than the item version of it in an inventory should have a "special case" written for it. There wouldn't actually be very many of them I don't think, off the top of my head I can only think of logs, water, sugarcane, lava, redstone torches (off state has a different damage number I believe), repeaters, and coal.
Cruor #10
Posted 09 October 2012 - 10:12 PM
Compare code have been updated to use the "middle click" function, so this is fixed in the next version of cc. This means IE stairs placed in any way is detected as a stair.

Cloudy:lockThreadForMe()