Jump to content




missing 'then' ?!


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

#1 HennoTM

  • New Members
  • 1 posts

Posted 01 January 2015 - 04:34 PM

Hey there!

Today i wanted to make a program for my farming turtle.
It's already pretty good, but i wanted to make it better (of course).
So i tried to use turtle.getItemDetail() and tried in a "Test" program how to use it.
My text is this:

data = turtle.getItemDetail()

if data.name = minecraft:wheat_seeds then
write("There are seeds!\n")
end

When i run the program the computer writes an error:

bios:366: [string "Test"]:3: 'then' expected

I wrote a 'then' so i don't understand the mistake.
Maybe you can help me...

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 01 January 2015 - 11:58 PM

Ah, no, it says it expected "then", not that you're missing "then". This error is covered in the Common Errors section of the Read This Post Before Asking Questions topic that you read all the way through before asking a question.

#3 wieselkatze

  • Members
  • 221 posts
  • LocationGermany

Posted 02 January 2015 - 01:03 AM

To clarify - you do actually have a malformed if-then expression there.
One error is already covered in Lyqyd's post - you're using '=' instead of '=='.
Your other mistake is comparing data.name to minecraft:wheat_seeds - that should be a string; meaning that it should either be marked in double or single quotation marks.
The correct code would look like this:

data = turtle.getItemDetail()

if data.name == "minecraft:wheat_seeds" then
  write("There are seeds!\n")
end

By the way: Instead of using a write() with \n at the end of the string, you could also just use print().

Edited by wieselkatze, 02 January 2015 - 01:04 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users