Operations & conditions
Operations & conditions can be performed on variables, depending on their type and values
Basic math operations
Neurox has 4 built-in functions for the 4 basic math operations :
SUM
SUB (subtract)
MPY (multiply)
DIV (divide)
Example :
DEFINE NEUROX
SUM(5,5) // 5 + 5
SUB(5,1) // 5 - 1
MPY(6,7) // 6 * 7
DIV(15,3) // 15 / 3
>>> 10
>>> 4
>>> 42
>>> 5They automatically print the result in the console if written like this.
You can also perform math operations with variables.
It is possible to store the result of an operation in a variable, but it won't be printed in the console.
Operation between integers and floats
As they have different type, they can still be used together for math operations. It will automatically converts the result to a float. This is a LuaU feature.
Concatenate two strings
You can concatenate (assemble) two strings together with the SUM function.
It works with variables as well. You can store the result in a variable too.
Warning : you can't perform SUB, MPY and DIV on strings.
Conditions and boolean operations
Simple condition with IF
A condition always start with IF followed by a condition. If the condition is true, the content of the condition block will be executed.
A condition always ends with END . If the condition is not true, nothing will happen.
Condition with ELSE and ELSEIF
If the condition is not true, you can set an ELSE statement.
In this case, the v3 value will be set to "v1 is less than v2"
If you desire to add another condition, use the ELSEIF statement
Comparison operators
You can use the following operators in conditions with Neurox :
<less than>greater than==equality!=inequality<=less or equal>=greater or equal
These operators always result in false or true.
= and == are totally different. One equal symbol is used to set values to variables and double equal is used as an operator.
Logical Operators
In Neurox, logical operators are and, or and not. They work exactly like LuaU operators :
The negation operator not always returns false or true. The conjunction operator and returns its first argument if this value is false or nil; otherwise, and returns its second argument. The disjunction operator or returns its first argument if this value is different from nil and false; otherwise, or returns its second argument. Both and and or use short-circuit evaluation; that is, the second operand is evaluated only if necessary. Here are some examples:
Last updated