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

getItemDetail: two different items return same data.name

Started by meigrafd, 23 July 2015 - 03:53 PM
meigrafd #1
Posted 23 July 2015 - 05:53 PM
Hi

Im using MineCraft 1.7.10 with Direwolf20 1.5 Modpack and getting sick with "new" Auto-Workbench when the 9 slots are full with same items but need 3 differents…

So i had the idea to code a Script for Turtles to Autocraft… But now i have a stupid problem:

In slot#5 is: Tin Plate
In slot#6 is: Iron Plate

But turtle.getItemDetail(5) and getItemDetail(6) returns the same name! :angry:/> -> IC2:itemPlates

How can i fix that? :wacko:/>

I want that the turtle gets the respective object from a chest… But dont want to hardcode it


Heres the debug code:
local InSlots = {1,2,3, 5,6,7, 9,10,11}

for i=1, #InSlots do
	local data = turtle.getItemDetail(InSlots[i])
	if data then
		print(InSlots[i]..": "..data.name)
	end
end
Edited on 23 July 2015 - 03:57 PM
Balthamel #2
Posted 23 July 2015 - 06:00 PM
Metadata is different
meigrafd #3
Posted 23 July 2015 - 06:02 PM
And what should that mean?

I dont want to inspect a Block. I want to check the Items in Slots of the turtle himself
Edited on 23 July 2015 - 04:50 PM
MKlegoman357 #4
Posted 23 July 2015 - 06:34 PM
The data.damage value is probably different.
Bomb Bloke #5
Posted 24 July 2015 - 01:04 AM
Indeed, it'll probably be a change in the damage value (items in an inventory don't have metadata).

To elaborate: minecraft:log is oak if the damage is 0, or spruce if the damage is 1, and so on.

However, it's possible the identity is determined by the item's NBT data (as it is with player / mob heads). ComputerCraft offers no way to get that information out of blocks or items. The addon mod RandomPeripherals does, but I've no idea if that's still compatible with recent CC versions.
meigrafd #6
Posted 26 July 2015 - 09:56 AM
I've solved the Problem over the Damage value.

My Second Problem was to get the Damage value from the Item in Chest… But OpenPeripheral doesnt support this and i dont want to install another Mod (like Turtle Item Analyzer) because with modpack direwolf20 i already have 148 mods..

I solved this by getting each Item from the Chests into Turtle, then using turtle.getItemDetail(16) and putting the Item back in Chest…

Now i have a realy cool working Auto-Craft Turtle: http://www.computercraft.info/forums2/index.php?/topic/24140-auto-crafty-turtle/

Thanks for your Help :)/>
Bomb Bloke #7
Posted 26 July 2015 - 01:06 PM
My Second Problem was to get the Damage value from the Item in Chest… But OpenPeripheral doesnt support this

Are you sure? Last I knew OpenPeripheral returned damage values just fine (via a "dmg" key). Granted, that was a while ago, but I don't see why they'd drop such a basic feature.