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

What's wrong with this?

Started by Dlcruz129, 22 November 2012 - 08:22 AM
Dlcruz129 #1
Posted 22 November 2012 - 09:22 AM
http://pastebin.com/mq0eg2VP

The error is:
bios:388: [string "startup"]:21: 'then' expected

Line 21 is:

if output = true then
Kingdaro #2
Posted 22 November 2012 - 09:29 AM
The equal sign should be a double equal sign. Single equal signs are only used for setting variables. In ifs, you need to use the double equal sign.


if output == true then 
Dlcruz129 #3
Posted 22 November 2012 - 09:34 AM
The equal sign should be a double equal sign. Single equal signs are only used for setting variables. In ifs, you need to use the double equal sign.


if output == true then

Oh of course, instead of Lua saying "= expected", it had to give me a magical quest for finding my bug.
ChunLing #4
Posted 22 November 2012 - 09:40 AM
Lua thinks that you wanted to assign output = true, which would be perfectly valid usage. It was just letting you know that you didn't create a valid if then structure.

You can get away with "if output then … end", and you probably should in a case like this if you normally have this kind of problem. The comparison operators should be reserved for when you actually need to do a comparison rather than check for whether something is already true.