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

Help with Turtle API?

Started by moneymaster2012, 21 December 2015 - 06:41 PM
moneymaster2012 #1
Posted 21 December 2015 - 07:41 PM
I am a beginner with turtles, and I don't know how to work them. I am trying to make a program where the turtle sucks up an item, and if it is a gold ingot, it runs some code. But if it is not, it runs different code. This is my attempt on how to do what I want, but it failed.


rednet.open("left")
suck = turtle.suck()
gold = "minecraft:gold_ingot"
if suck == true then
  count,name,damage = turtle.getItemDetail()
  if name == gold then
	print("YES!")
  else
	print("no!")
  end
else
  print("false")
end

I would like some help ASAP.
Thank you! :D/>
Edited on 21 December 2015 - 08:15 PM
Lupus590 #2
Posted 21 December 2015 - 08:05 PM
describe how it failed, did it think everything is gold? nothing is gold? was there an error message produced?
Edited on 21 December 2015 - 07:05 PM
moneymaster2012 #3
Posted 21 December 2015 - 08:11 PM
describe how it failed, did it think everything is gold? nothing is gold? was there an error message produced?

It thought that nothing was gold. Sorry, I should've said that in the post.
Edited on 21 December 2015 - 07:11 PM
Lupus590 #4
Posted 21 December 2015 - 09:14 PM
detail is equal to nil, you should be using name in your if statement
moneymaster2012 #5
Posted 21 December 2015 - 09:18 PM
detail is equal to nil, you should be using name in your if statement

Okay, I fixed that, but it still comes up with the same problem.
Lupus590 #6
Posted 21 December 2015 - 11:00 PM
the count and name vars are the wrong way round, turtle.getItemDetails returns name first , followed by count and then damage