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
[LUA] '=' expected
Started by Kexus, Jun 19 2012 07:29 PM
8 replies to this topic
#1
Posted 19 June 2012 - 07: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.
#2
Posted 19 June 2012 - 07:46 PM
You missed the brackets here:
turtle.turnRightshould be:
turtle.turnRight()
#3
Posted 19 June 2012 - 07: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.
EDIT: Been MysticT ninja'd. Again.
#4
Posted 19 June 2012 - 09:01 PM
Heh, you can pen them in? Let them randomly chose up and down every once in a while, and set them freeee!
#5
Posted 19 June 2012 - 09: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
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
#6
Posted 20 June 2012 - 01: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.
#7
Posted 24 July 2013 - 05: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
local x = 5
if x==5 then
function{} redset left true
end
#9
Posted 24 July 2013 - 06:33 PM
yoro, on 24 July 2013 - 05:36 PM, said:
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
local x = 5
if x==5 then
function{} redset left true
end
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.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











