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

Get name of item in inventory slot

Started by Gamezdude, 28 June 2014 - 08:28 AM
Gamezdude #1
Posted 28 June 2014 - 10:28 AM
In a turtle i need to get the name (string) of an item in the selected inventory slot to use in a if statement
I just need to know how to get it item slot as a string (the item itself) not a number/Integer

turtle.select(4)
–Get item name (String)
if item == "Iron ore" then
–do stuff
end
NanoBob #2
Posted 28 June 2014 - 11:16 AM
You can not directly see an items id/name with the turtle. However you can put it in a chest and then (If you have open peripheral) Use the chest as a peripheral to find out the obejct ID and name.
Lignum #3
Posted 28 June 2014 - 11:24 AM
Judging by your example code, turtle.compareTo may be able to help you.
theoriginalbit #4
Posted 28 June 2014 - 01:07 PM
if you have OpenPeripheral-Addons installed you can create a Narcissistic Turtle by crafting the Turtle with a Duck Antenna, this allows you to use inventory functions on the Turtle's inventory.