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

[1.63][SMP/SSP]turtle.compareTo() not matching items with different damage values.

Started by Xastabus, 14 October 2014 - 02:27 AM
Xastabus #1
Posted 14 October 2014 - 04:27 AM
VERSION:
ComputerCraft 1.63


DESCRIPTION:
turtle.compareTo previously returned "true" on items with matching IDs regardless of damage values. This was useful for repairing armor and tools, now it doesn't work. Now turtle.compareTo only returns "true" if items have the same ID and the same damage value. A replacement for the original functionality has not been provided in a MC 1.6.4 compatible version of ComputerCraft.


EXPECTED RESULT:
In ComputerCraft 1.58 items with the same ID but different damage values would return "true" when compared by turtle.compareTo. This allowed Crafty Turtles to repair armor and tools when given a large number of damaged items to sort through.


REPRODUCTION STEPS:

Place a Turtle

Give the player multiples of an armor or tool with random damage values with at least two having the same damage value. All items must be of the same ID.

Place the items in the turtle

enter the following test program

bMax=3 --[[Set to number of filled slots]]--
for a=1,bMax do
  turtle.select(a)
  for b=a+1,bMax do
	c=turtle.compareTo(B)/>/>
	print(a," = ",b,"? ",c)
  end
end

execute the test program.

Under previous behavior all print lines would have been true regardless of random damage values on like items.

SCREENSHOT/VIDEO:

Example in ComputerCraft 1.58



Example in ConmputerCraft 1.63
Lyqyd #2
Posted 14 October 2014 - 07:45 AM
The turtle.getItemDetail call will allow you to check this, in CC 1.64+. Historically, there is no feature back porting to previous versions, so this functionality is unlikely to be made available for MC 1.6.4. This is made yet more unlikely due to 1.6.4 being a version that uses item IDs rather than names. In addition, the actual bug involved was fixed (compareTo not taking metadata/damage into account when it should), not created, when the behavior was changed.

Sorry, you'll likely have to update to MC 1.7.10 to take advantage of the new functionality, or use a mod like OpenPeripherals that would let you examine the turtle's inventory contents directly. If you are playing in a major mod pack, you likely have OpenP installed already, so it may be the best solution to the problem you're facing.
Xastabus #3
Posted 14 October 2014 - 03:14 PM
Thank you for your reply. That is unfortunate, upgrading to 1.7.10 is not currently an option for my world as several mods I rely on have not been ported to it yet and based on author activity may have been abandoned.

Since I upgraded ComputerCraft, OpenPeripherals seems to have stopped working. I found http://www.computerc...openperipheral/ and followed links to download updates for it. I have not gotten into it yet so it will take time…

Alternately I have also added OpenComputers to my build. This mod is being maintained for both 1.6.4 and 1.7.10. I will have to see if its robots are capable of performing the test I need.

My findings will be added to the post in the following link.
http://www.computerc...post__p__196127