Lua is a scripting language widely used for games due to its simplicity and readability. Lua can be used to modify and store variables as well as call functions defined in the main application. Below is a brief primer on the Lua language but you can learn more by reading the Lua 5.1 reference manual.
Variables
Variables in Lua are used to store a piece of information, such as a text value, numeric value, or a boolean value (true/false). A variable can be set using the equals sign:
variable_name1 = "text"
variable_name2 = value
variable_name3 = false
Note: The boolean variable is case-sensitive and must be lowercase.
One additional type of variable in Lua is called the Table. If you are familiar with programming, a table is much like a class where the table may store many additional variables, or properties, within it. A variable stored within a table can be accessed using either square brackets, or dot notation:
table_name["variable_name"] = value
table_name.variable_name = value
Arithmetic Operators
Lua supports all of the most common arithmetic operations on variables and values including addition (+), subtraction (-), multiplication (*), division (/), modulo (%), exponentiation (^), and negation (~). Note that Lua does not support the ++ or -- operators found in some programming languages, so to increment a variable value, you must use:
variable = variable + 3
Function Calls
If functions are available to the scripting language, they may be called by using the following notation:
function_name(parameter1, parameter2, ...)
Although some functions do not require any parameters at all. For more information on the functions available in Chat Mapper, see the next section.
Relational Operators
Relational operators always produce either a true or false response by comparing variables to some value or another variable. The most common operators are:
== : Equal - Compares two values or variables and returns true if they are equal.
~= : Not Equal - Returns the opposite value of the equal operator.
For a full list of operators, see the Lua reference manual.
Logical Operators
Logical operators combine multiple relational operators to allow for complex expressions. The available logical operators are and, or, and not.
20 == 20 or 20 == 10 returns true because the first half is true.
20 == 20 and 20 ==10 returns false because only one of the two statements is true.