Jump to content




Help with Turtle API?


  • You cannot reply to this topic
5 replies to this topic

#1 moneymaster2012

  • Members
  • 38 posts

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 by moneymaster2012, 21 December 2015 - 09:15 PM.


#2 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

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 by Lupus590, 21 December 2015 - 08:05 PM.


#3 moneymaster2012

  • Members
  • 38 posts

Posted 21 December 2015 - 08:11 PM

View PostLupus590, on 21 December 2015 - 08:05 PM, said:

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 by moneymaster2012, 21 December 2015 - 08:11 PM.


#4 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 21 December 2015 - 09:14 PM

detail is equal to nil, you should be using name in your if statement

#5 moneymaster2012

  • Members
  • 38 posts

Posted 21 December 2015 - 09:18 PM

View PostLupus590, on 21 December 2015 - 09:14 PM, said:

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.

#6 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

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





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users