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

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

Started by lare290, 12 December 2014 - 08:52 PM
lare290 #1
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?
Bomb Bloke #2
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.
lare290 #3
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 on 12 December 2014 - 09:23 PM
Bomb Bloke #4
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.
lare290 #5
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?
Bomb Bloke #6
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.
lare290 #7
Posted 12 December 2014 - 11:08 PM
I saw text.input somewhere :P/>
Geforce Fan #8
Posted 12 December 2014 - 11:34 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
In if statements, it should be
 if variable == "yes" then
so basically, drop the parenthesis on the if statement.
Edited on 12 December 2014 - 10:36 PM
Dragon53535 #9
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 =