I'm just starting out using Lua, and I was wondering (because I can't find it on the website) if Lua has a OR operator, like how in other languages there is ||:
if (condition == true || othercondition == false) { somecode.somefunction(); }
whereas in Lua, there is
if condition then x = 0 end
how would i write an IF block in Lua to use OR?
++ is not a C function, it is an operator. So Lua being able to use C functions is not applicable.
Unfortunately, this will not work, as standard Lua is written in C, which, while very similar to C# in it's structure, is not C# and is not compatible with the . NET framework.
(A == B) is not true. Checks if the value of two operands are equal or not, if values are not equal then condition becomes true. (A ~= B) is true. Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.
The ~= symbol or operator in Lua is known as the not-equal to operator. In many programming languages you might have seen the symbol != which is also known as the not equals operator.
With "or".
if condition or not othercondition then x = 0 end
As the Lua manual clearly states.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With