Programming‎ > ‎Language‎ > ‎Lua‎ > ‎

Standard Libraries


The standard Lua libraries provide useful functions and are implemented as separate C modules. Besides the basic and package libraries they all provides its functions as fields in a global table or as methods of its objects. The host program can load them all with luaL_openlibs or specific ones with  luaL_requiref.

collectgarbage ([opt [, arg]])
Function to control the garbage collector. Opt is a string that is used to select what to tell the garbage collector to do.

error (message [, level])

A global variable that holds the global environment.

getmetatable (object)

ipairs (t)

next (table [, index])

pairs (t)

print (···)

setmetatable (table, metatable)

tonumber (e [, base])

tostring (v)
Convert v to a string. If v has a metatable __tostring field it is called and used to get the result.

type (v)
Returns the type of v as a string.


string - String Manipulation
This library have all it's functions inside the table string. It is also set as a metatable for values of the type string so it is possible to use string in a object-oriented style. Strings are index with the first character at position 1. Negatived indexes are used to index backwards from the end of the string.

table - Table Manipulation

math - Mathematical Functions

io - Input and output

os - Operating system