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

Name of item from inventory

Started by Robinlemon, 22 November 2015 - 01:08 AM
Robinlemon #1
Posted 22 November 2015 - 02:08 AM
using a turtle to scan chests for items, is there a name property for each item? Currently using safari nets.


a = peripheral.wrap("left")
itemTbl = a.getStackInSlot(1)
for k, v in pairs(itemTbl) do
   print(k..": "..tostring(v))
end

The output is:

raw_name: item.mfr.safarinet.reusable
max_dmg: 0
max_size: 1
dmg: 0
id: MineFactoryReloaded:safarinet,reusable
nbt_hash: 23536b81e69c21ea30ba6d754ffd9bba
ore_dict: table: ——–
safari_net: table: —————–
name: safarinet.reuable
mod_id: MineFactoryReloaded

Although the safari net is called "Pink Slime", i cant find a property to get the name if you look at the safari_net table it will give you the property "captured": MineFactoryReloaded.mfrEntityPinkSlime, although cutting and rebuilding this as a string for the name would be extremely over complicated and something that id want to avoid.
Bomb Bloke #2
Posted 22 November 2015 - 03:52 AM
If it's not in there, it's not in there. Exactly what info you get varies a bit depending on the version of OpenPeripherals you're using.

Though I gather it's pretty good about returning labels for items which've been named with an anvil.
KingofGamesYami #3
Posted 22 November 2015 - 03:55 AM
Actually, cutting up that string for the name is quite simple.


local name = itemTbl.safari_net.captured:match( "Entity(%a+)" )
print( name ) --#prints PinkSlime

I use a pattern to match every letter in the string after "Entity"
Robinlemon #4
Posted 22 November 2015 - 04:09 PM
Actually, cutting up that string for the name is quite simple.


local name = itemTbl.safari_net.captured:match( "Entity(%a+)" )
print( name ) --#prints PinkSlime

I use a pattern to match every letter in the string after "Entity"

Thanks, although I figured out that there's a display_name property which shows the name of the item, which I've renamed in an anvil.