-1

I have this if statement and when I run it it reeturns an error : " ')' expected "

if (a=1 and b=4 and c=width/2) or (a=2 and b=1 and c=width/2) then
...
end

Am I doing something wrong here? or is it something wrong with lua?

3
  • I think your = need to be ==. = sets a value while == compares values.
    – showdev
    Commented Apr 16, 2013 at 23:34
  • Not that I know much about Lua.. But should it not be == and not =?
    – MAV
    Commented Apr 16, 2013 at 23:34
  • If the below helped you solve your problem you should mark it as answer. Here's how you do it: meta.stackexchange.com/questions/5234/…
    – ArchiFloyd
    Commented Apr 17, 2013 at 10:30

1 Answer 1

6

Try to replace your current code with this:

if (a==1 and b==4 and c==width/2) or (a==2 and b==1 and c==width/2) then
...
end

= means assignment, whereas == checks for equality and it looks like you want to check for equality.

1
  • Oh haha i forgot that, Im so used to xcode which tells me if i make that mistake :P
    – Arbitur
    Commented Apr 17, 2013 at 8:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.