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

[LUA] '=' expected

Started by Kexus, 19 June 2012 - 06:29 PM
Kexus #1
Posted 19 June 2012 - 08:29 PM
I made a very simple program for my turtles, where they simple move until they bump into something, and then randomly turn either left or right. When I run it it says [string "wander]:8: '=' expected. I have no clue why it would want = there, since I already have ==, which it what should be there.

while true do
repeat
turtle.forward()
until turtle.detect()
turn = math.random(1,2)
if turn == 2 then
turtle.turnLeft
elseif turn == 1 then
turtle.turnRight
end
MysticT #2
Posted 19 June 2012 - 08:46 PM
You missed the brackets here:

turtle.turnRight
should be:

turtle.turnRight()
OmegaVest #3
Posted 19 June 2012 - 08:47 PM
You forgot the () after turnLeft. Sometimes the debugger freaks out when it cannot figure out what is wrong, so it tells you the next nearest thing is wrong in a common manner. No idea why.

EDIT: Been MysticT ninja'd. Again.
kazagistar #4
Posted 19 June 2012 - 10:01 PM
Heh, you can pen them in? Let them randomly chose up and down every once in a while, and set them freeee!
DrFreenote #5
Posted 19 June 2012 - 10:11 PM
I'm no professional, though my theory on why it's expecting '=' on line 8 is because it reads turtle.turnLeft without the brackets as a variable instead of a function. Typically variables are assigned via the '=' character, so when it reaches line 8 and bumps into the elseif statement, it says "Woah, hey. Wait a minute. Where did that equal sign go?" and pops an error on the spot.

It's good to keep this behavior in mind when debugging code. I never only check the line in question, I always check around it as well. It saves a lot of headaches. =3
Kexus #6
Posted 20 June 2012 - 02:00 AM
Ok guys, thanks. I'm used to Python, where you only need parenthesis if you are using arguments. I'll get the hang of this eventually.
yoro #7
Posted 24 July 2013 - 06:36 PM
i am having the same problem my program is extremely simple all it is is

local x = 5

if x==5 then
function{} redset left true
end
MR_nesquick #8
Posted 24 July 2013 - 07:11 PM
–snip–

yoro pleas start a new topic where you can tell us what exactly you are trying to do.
Engineer #9
Posted 24 July 2013 - 07:33 PM
i am having the same problem my program is extremely simple all it is is

local x = 5

if x==5 then
function{} redset left true
end
Hmm..
I dont get what you are trying to do. But the problem is that you are declaring a function, not correct, it requires parenthesis, and to add to that you are using invalid programming language.

Im just guessing here, but I think you are looking for this particular function:

shell.run( "Redset left true" )
shell.run is a function where you can run other programs on the particular computer.

I am not sure if you are looking for this, so please clearify what you are trying to do. Also, I would recommend to do that with all questions you have, we cant smell where a=you are having a problem with.