Jump to content




bios:366: [string "turtle"]:3: 'then' excepted


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

#1 lare290

  • Members
  • 53 posts
  • LocationFinland

Posted 12 December 2014 - 09:52 PM

it says thing in title when I try to run this in turtle:

text.input ("Do sir want some drinks?")
variable = read()
if variable = ("yes") then
turtle.drop()
end
What am I f*cking up here?

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 12 December 2014 - 10:09 PM

Lua doesn't expect to see a variable assignment using = there, so it complains at you. == is used for "is equal" comparisons.

#3 lare290

  • Members
  • 53 posts
  • LocationFinland

Posted 12 December 2014 - 10:11 PM

now it says "bios:366: [string "turtle"]:2: '=' excepted

text.input ("Do sir want some drinks?")
variable == read()
if variable == ("yes") then
turtle.drop()
end

Edited by lare290, 12 December 2014 - 10:23 PM.


#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 12 December 2014 - 10:24 PM

Take a look at this. If you're still having trouble, post the new version of the code.

#5 lare290

  • Members
  • 53 posts
  • LocationFinland

Posted 12 December 2014 - 10:47 PM

So it didn't like text.input, i had to use write for it to work. why was that?

#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 12 December 2014 - 10:52 PM

To memory, I don't there is a text.input, at least, not unless you pre-defined one somewhere else.

#7 lare290

  • Members
  • 53 posts
  • LocationFinland

Posted 12 December 2014 - 11:08 PM

I saw text.input somewhere :P

#8 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 12 December 2014 - 11:34 PM

View Postlare290, on 12 December 2014 - 10:11 PM, said:

now it says "bios:366: [string "turtle"]:2: '=' excepted

text.input ("Do sir want some drinks?")
variable == read()
if variable == ("yes") then
turtle.drop()
end
In if statements, it should be
 if variable == "yes" then
so basically, drop the parenthesis on the if statement.

Edited by Geforce Fan, 12 December 2014 - 11:36 PM.


#9 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 13 December 2014 - 12:15 AM

print("Do sir want some drinks?")
variable = read()
if variable == ("yes") then
turtle.drop()
end

This should work. If you want to display text, use print/write/term.write
When setting a value, you need only one =
When checking if two values are the same, you need two =





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users