Jump to content




[LUA] '=' expected


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

#1 Kexus

  • New Members
  • 7 posts

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.
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


#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 19 June 2012 - 07:46 PM

You missed the brackets here:
turtle.turnRight
should be:
turtle.turnRight()


#3 OmegaVest

  • Members
  • 436 posts

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.

#4 kazagistar

  • Members
  • 365 posts

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 DrFreenote

  • New Members
  • 7 posts

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

#6 Kexus

  • New Members
  • 7 posts

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 yoro

  • New Members
  • 1 posts

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

#8 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

Posted 24 July 2013 - 06:11 PM

View Postyoro, on 24 July 2013 - 05:36 PM, said:

--snip--

yoro pleas start a new topic where you can tell us what exactly you are trying to do.

#9 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 24 July 2013 - 06:33 PM

View Postyoro, 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
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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users