-4

I'm learning how to use the LOVE engine, which uses Lua, but this engine cannot identify an error about, you know, if you need to do this:

if value=1 then

or

if value==1 then

to the engine identify a variable, so I'm asking this to prevent errors.

Oka
  • 23,367
  • 6
  • 42
  • 53
arthurgps2
  • 101
  • 1
  • 7
  • Lua is better than most languages about this, since `value = 1` is not an expression, so it cannot go in an `if` statement. You should have gotten a compile error when you tried to execute that. – Nicol Bolas Oct 15 '16 at 03:12
  • Very unclear what it is you are asking here. The first line of code would cause a syntax error at runtime, crashing your program. `=` is assignment, `==` is equality. [RTFM](https://www.lua.org/manual/5.1/). – Oka Oct 15 '16 at 03:28
  • 1
    @NicolBolas - The compilation error is the following: `'then' expected near '='`. Of course, this is very cryptic for beginner to understand the real reason of the error. – Egor Skriptunoff Oct 15 '16 at 10:49
  • You can't prevent errors; you have to reduce and manage them. Reading a manual is one way to reduce them. The Lua Reference Manual is concise and straightforward. To manage errors, you can use tools such as compilers, IDEs and tests. `luac` is a compiler that you likely have already. See the tag info pages for [Lua](http://stackoverflow.com/tags/lua/info) and [LÖVE](http://stackoverflow.com/tags/love2d/info). – Tom Blodget Oct 15 '16 at 14:03

1 Answers1

0

if value==1 then etc.

As you can read here https://www.lua.org/manual/5.1/manual.html#2.5.2 and here https://www.lua.org/pil/3.2.html or just here http://www.google.com/

DarkWiiPlayer
  • 6,871
  • 3
  • 23
  • 38