6.1 – Basic Functions

The basic library provides core functions to Lua. If you do not include this library in your application, you should check carefully whether you need to provide implementations for some of its facilities.

collectgarbage()
  • References/Lua/Lua/Standard Libraries/Basic Functions

collectgarbage ([opt [, arg]]) This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt:

2025-01-10 15:47:30
pairs()
  • References/Lua/Lua/Standard Libraries/Basic Functions

pairs (t) If t has a metamethod __pairs, calls it with t as argument and returns the first three results from the call. Otherwise

2025-01-10 15:47:30
select()
  • References/Lua/Lua/Standard Libraries/Basic Functions

select (index, ···) If index is a number, returns all arguments after argument number index; a negative number indexes from the end (-1 is the last argument)

2025-01-10 15:47:30
rawequal()
  • References/Lua/Lua/Standard Libraries/Basic Functions

rawequal (v1, v2)v1v2__eq

2025-01-10 15:47:30
xpcall()
  • References/Lua/Lua/Standard Libraries/Basic Functions

xpcall (f, msgh [, arg1, ···]) This function is similar to pcall, except

2025-01-10 15:47:30
rawset()
  • References/Lua/Lua/Standard Libraries/Basic Functions

rawset (table, index, value)table[index]value__newindextableindexnilvalue This function returns

2025-01-10 15:47:30
setmetatable()
  • References/Lua/Lua/Standard Libraries/Basic Functions

setmetatable (table, metatable) Sets the metatable for the given table. (To change the metatable of other types from Lua code, you must use the debug library (

2025-01-10 15:47:30
assert()
  • References/Lua/Lua/Standard Libraries/Basic Functions

assert (v [, message]) Calls error if the value of its argument v

2025-01-10 15:47:30
type()
  • References/Lua/Lua/Standard Libraries/Basic Functions

type (v)nilnilnumberstringbooleantablefunctionthreaduserdata

2025-01-10 15:47:30
tostring()
  • References/Lua/Lua/Standard Libraries/Basic Functions

tostring (v)string.format If the metatable of v

2025-01-10 15:47:30