Skip to content

Help using turtle.getItemDetail() #1565

Answered by Lupus590
SoundMeister asked this question in Q&A
Discussion options

You must be logged in to vote

My best advice would be to play around in the Lua REPL1 prompt and get it to pretty print the result of get item detail.

I'm expecting you to do this in the Lua prompt so we are not using local, the interactive prompt doesn't handle local the same way that programs do2.

 pretty = require("cc.pretty")
 item = turtle.getItemDetail()
 pretty.pretty_print(item)

From there you'll see a table printed out, the value that you are interested in is stored in the name key. To access that in your program you'll probably do something like this.

local  item = turtle.getItemDetail()
if item and item.name == "minecraft:wheat_seeds" then -- Note that I might have the internal name for the seeds wrong, I'm…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@SoundMeister
Comment options

@Lupus590
Comment options

Answer selected by SquidDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants