table.sort()

table.sort (list [, comp]) Sorts list elements in a given order, in-place, from list[1] to list[#list]. If comp is given, then it must be a function that receives two list elements and returns true when the first element must come before the second in the final order (so that, after the sort, i < j implies not comp(list[j],list[i])). If comp is not given, then the standard Lua operator < is used instead. Note that the comp function must define a strict partial order over the elements

lua_dump

lua_dump[-0, +0, –] int lua_dump (lua_State *L, lua_Writer writer, void *data, int strip); Dumps a function as a binary chunk. Receives a Lua function on the top of the stack and produces a binary chunk that, if loaded again, results in a function equivalent to the one dumped. As it produces parts of the chunk, lua_dump calls function writer (see lua_Writer) with the given data to write them. If strip is true, the bina

lua_sethook

lua_sethook[-0, +0, –] void lua_sethook (lua_State *L, lua_Hook f, int mask, int count); Sets the debugging hook function. Argument f is the hook function. mask specifies on which events the hook will be called: it is formed by a bitwise OR of the constants LUA_MASKCALL, LUA_MASKRET, LUA_MASKLINE, and LUA_MASKCOUNT. The count argument is only meaningful when the mask includes LUA_MASKCOUNT. For each event, the hook is called as explained below: The call hook: is called when the interpre

Bitwise Operators

3.4.2 – Bitwise Operators Lua supports the following bitwise operators: &: bitwise AND |: bitwise OR ~: bitwise exclusive OR >>: right shift <<: left shift ~: unary bitwise NOT All bitwise operations convert its operands to integers (see §3.4.3), operate on all bits of those integers, and result in an integer. Both right and left shifts fill the vacant bits with zeros. Negative displacements shift to the other direction; displacements with absolute values equal to o

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

lua_getuservalue

lua_getuservalue[-0, +1, –] int lua_getuservalue (lua_State *L, int index); Pushes onto the stack the Lua value associated with the full userdata at the given index. Returns the type of the pushed value.

os.getenv()

os.getenv (varname) Returns the value of the process environment variable varname, or nil if the variable is not defined.

Table Constructors

3.4.9 – Table Constructors Table constructors are expressions that create tables. Every time a constructor is evaluated, a new table is created. A constructor can be used to create an empty table or to create a table and initialize some of its fields. The general syntax for constructors is tableconstructor ::= ‘{’ [fieldlist] ‘}’ fieldlist ::= field {fieldsep field} [fieldsep] field ::= ‘[’ exp ‘]’ ‘=’ exp | Name ‘=’ exp | exp fieldsep ::= ‘,’ | ‘;’ Each field of the form [exp1] = exp2 adds

lua_getfield

lua_getfield[-0, +1, e] int lua_getfield (lua_State *L, int index, const char *k); Pushes onto the stack the value t[k], where t is the value at the given index. As in Lua, this function may trigger a metamethod for the "index" event (see §2.4). Returns the type of the pushed value.

table.unpack()

table.unpack (list [, i [, j]]) Returns the elements from the given list. This function is equivalent to return list[i], list[i+1], ···, list[j] By default, i is 1 and j is #list.