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

Wierd if-statement ')' error

Started by alron, 26 December 2012 - 02:30 AM
alron #1
Posted 26 December 2012 - 03:30 AM
I have this pice of Code(in the program digQuader:


function turn(dir, height)
  if(dir = "right") then --on this line it says ')' expected!
    turtle.turnRight()
    turtle.forward()
    ...
  end
end

that gives me the error: bios:338: [string "digQuader"]:20: ')' expected

I really can't figure out what's wrong.
Can anyone help?
Cozzimoto #2
Posted 26 December 2012 - 03:48 AM
all comparions need to be "=="


function turn(dir, height)
if(dir == "right") then
turtle.turnRight()
turtle.forward()

end
end
alron #3
Posted 26 December 2012 - 03:55 AM
Shame on me!
I don't know how i didn't notice that. I literally sat there about half an hour trying to figur it out.
Thanks anyways.
Cozzimoto #4
Posted 26 December 2012 - 09:15 AM
when i am tire i make little mistakes too like yours, everyone does it. if it hasnt been done already i want to make some sort of syntex checker program and if it returns an error it fixes it automatically for me, that would be very nice and have alot of hours for everyone when attemping to debug their programs, esp when a single program gets greater than 200 lines like some of mine that i have. =(

maybe i can start working on something like that right now =) *inspiration fired*