Skip to content

Lua Global

The following is a list of functions and variables that are native to Lua 5.1.

Functions

boolean rawequal(table o1, table o2)
Compares the value or reference of o1 and o2.
string type(table o)
Returns the type of its arguments as string.
string tostring(table o)
Returns the string message of its arguments.
number tonumber(string o)
Converts the string to a number.
  • o a string convertible to a number
number tonumber(number o)
Returns the the argument self.
table assert(... arguments)
Returns arguments if the first arguments is not false or nil, or an error issued.
void error(table o)
Issues an error with o as the message.
  • o The error message.
boolean pcall(function func, ... arguments)
Calls the c in a protected mode. When the call finishes without any error, the first return value is true followed by the return values of func.
boolean xpcall(function func, function handler)
Calls the c in a protected mode. When the error happened, the handler is called.
  • handler The error handler.
table ipairs(table table)
Returns the number index iterator of the table, which can be used in for loop.
table pairs(table table)
Returns the iterator of the table, which can be used in for loop.
table rawget(table table, table index)
Gets the real value of table[index], without calling any meta-method.
void rawset(table table, table index, table value)
Sets the real value of table[index], without calling any meta-method.
table unpack(... arguments)
Flattens down the table as multiple return values.
table select(number index, ... arguments)
Returns the index-th argument of the following arguments.
number select(string index, ... arguments)
Returns the count of arguments.
  • index The string "#".
void print(... arguments)
Receives any number of arguments, and prints their values to the output.