type()

type (v)nilnilnumberstringbooleantablefunctionthreaduserdata

tostring()

tostring (v)string.format If the metatable of v has a __tostring field, then tostring calls the corresponding value with v as argument, and uses the result of the call as its result.

tonumber()

tonumber (e [, base]) When called with no base, tonumber tries to convert its argument to a number. If the argument is already a number or a string convertible to a number, then tonumber returns this number; otherwise, it returns nil. The conversion of strings can result in integers or floats, according to the lexical conventions of Lua (see §3.1). (The string may have leading and trailing spaces and a sign.) When called with base, then e must be a string to be interpreted as an integer n

The Length Operator

3.4.7 – The Length Operator The length operator is denoted by the unary prefix operator #. The length of a string is its number of bytes (that is, the usual meaning of string length when each character is one byte). The length operator applied on a table returns a border in that table. A border in a table t is any natural number that satisfies the following condition: (border == 0 or t[border] ~= nil) and t[border + 1] == nil In words, a border is any (natural) index in a table where a n

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.

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

table.remove()

table.remove (list [, pos]) Removes from list the element at position pos, returning the value of the removed element. When pos is an integer between 1 and #list, it shifts down the elements list[pos+1], list[pos+2], ···, list[#list] and erases element list[#list]; The index pos can also be 0 when #list is 0, or #list + 1; in those cases, the function erases the element list[pos]. The default value for pos is #list, so that a call table.remove(l) removes the last element of list l.

table.pack()

table.pack (···) Returns a new table with all parameters stored into keys 1, 2, etc. and with a field "n" with the total number of parameters. Note that the resulting table may not be a sequence.

table.move()

table.move (a1, f, e, t [,a2]) Moves elements from table a1 to table a2, performing the equivalent to the following multiple assignment: a2[t],··· = a1[f],···,a1[e]. The default for a2 is a1. The destination range can overlap with the source range. The number of elements to be moved must fit in a Lua integer. Returns the destination table a2.

table.insert()

table.insert (list, [pos,] value) Inserts element value at position pos in list, shifting up the elements list[pos], list[pos+1], ···, list[#list]. The default value for pos is #list+1, so that a call table.insert(t,x) inserts x at the end of list t.