Logical Operators

3.4.5 – Logical Operators The logical operators in Lua are and, or, and not. Like the control structures (see §3.3.4), all logical operators consider both false and nil as false and anything else as true. 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; ot

math.min()

math.min (x, ···) Returns the argument with the minimum value, according to the Lua operator <. (integer/float)

Relational Operators

3.4.4 – Relational Operators Lua supports the following relational operators: ==: equality ~=: inequality <: less than >: greater than <=: less or equal >=: greater or equal These operators always result in false or true. Equality (==) first compares the type of its operands. If the types are different, then the result is false. Otherwise, the values of the operands are compared. Strings are compared in the obvious way. Numbers are equal if they denote the same mathemat

luaL_loadstring

luaL_loadstring[-0, +1, –] int luaL_loadstring (lua_State *L, const char *s); Loads a string as a Lua chunk. This function uses lua_load to load the chunk in the zero-terminated string s. This function returns the same results as lua_load. Also as lua_load, this function only loads the chunk; it does not run it.

debug.getupvalue()

debug.getupvalue (f, up) This function returns the name and the value of the upvalue with index up of the function f. The function returns nil if there is no upvalue with the given index. Variable names starting with '(' (open parenthesis) represent variables with no known names (variables from chunks saved without debug information).

luaL_optlstring

luaL_optlstring[-0, +0, v] const char *luaL_optlstring (lua_State *L, int arg, const char *d, size_t *l); If the function argument arg is a string, returns this string. If this argument is absent or is nil, returns d. Otherwise, raises an error. If l is not NULL, fills the position *l with the result's length. If the result is NULL (only possible when returning d and d == NULL), its length is considered

lua_gethook

lua_gethook[-0, +0, –] lua_Hook lua_gethook (lua_State *L); Returns the current hook function.

Function Calls

3.4.10 – Function Calls A function call in Lua has the following syntax: functioncall ::= prefixexp args In a function call, first prefixexp and args are evaluated. If the value of prefixexp has type function, then this function is called with the given arguments. Otherwise, the prefixexp "call" metamethod is called, having as first parameter the value of prefixexp, followed by the original call arguments (see §2.4). The form functioncall ::= prefixexp ‘:’ Name args can be used to call "

luaL_setfuncs

luaL_setfuncs[-nup, +0, m] void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup); Registers all functions in the array l (see luaL_Reg) into the table on the top of the stack (below optional upvalues, see next). When nup is not zero, all functions are created sharing nup upvalues, which must be previously pushed on the stack on top of the library table. These values are popped from the stack after the registration.

Coercions and Conversions

3.4.3 – Coercions and Conversions Lua provides some automatic conversions between some types and representations at run time. Bitwise operators always convert float operands to integers. Exponentiation and float division always convert integer operands to floats. All other arithmetic operations applied to mixed numbers (integers and floats) convert the integer operand to a float; this is called the usual rule. The C API also converts both integers to floats and floats to integers, as needed. M