position information to the
message.
_G *_G*
A global variable (not a function) that holds the global environment
(that is, `_G._G = _G`). Lua itself does not use this variable;
changing its value does not affect any environment, nor vice-versa.
(Use `setfenv` to change environments.)
getfenv({f}) *getfenv()*
Returns the current environment in use by the function. {f} can be a
Lua function or a number that specifies the function at that stack
level: Level 1 is the function calling `getfenv`. If the given
function is not a Lua function, or if {f} is 0, `getfenv` returns the
global environment. The default for {f} is 1.
getmetatable({object}) *getmetatable()*
If {object} does not have a metatable, returns `nil`. Otherwise, if
the object's metatable has a `"__metatable"` field, returns the
associated value. Otherwise, returns the metatable of the given
object.
ipairs({t}) *ipairs()*
Returns three values: an |iterator| function, the table {t}, and 0, so
that the construction
`for i,v in ipairs(t) do` `body` `end`
will iterate over the pairs (`1,t[1]`), (`2,t[2]`), ..., up to the
first integer key absent from the table.
load({func} [, {chunkname}]) *load()*
Loads a chunk using function {func} to get its pieces. Each call to
{func} must return a string that concatenates with previous results. A
return of `nil` (or no value) signals the end of the chunk.
If there are no errors, returns the compiled chunk as a function;
otherwise, returns `nil` plus the error message. The environment of
the returned function is the global environment.
{chunkname} is used as the chunk name for error messages and debug
information.
loadfile([{filename}]) *loadfile()*
Similar to `load` (see |load()|), but gets the chunk from file
{filename} or from the standard input, if no file name is given.
loadstring({string} [, {chunkname}]) *loadstring()*
Similar to `load` (see |load()|), but gets the chunk from the
given {string}.
To load and run a given string, use the idiom
>lua
assert(loadstring(s))()
<
next({table} [, {index}]) *next()*
Allows a program to traverse all fields of a table. Its first argument
is a table and its second argument is an index in this table. `next`
returns the next index of the table and its associated value. When
called with `nil` as its second argument, `next` returns an initial
index and its associated value. When called with the last index, or
with `nil` in an empty table, `next` returns `nil`. If the second
argument is absent, then it is interpreted as `nil`. In particular,
you can use `next(t)` to check whether a table is empty.
The order in which the indices are enumerated is not specified, even
for numeric indices. (To traverse a table in numeric order, use a
numerical `for` or the |ipairs()| function.)
The behavior of `next` is `undefined` if, during the traversal, you
assign any value to a non-existent field in the table. You may however
modify existing fields. In particular, you may clear existing fields.
pairs({t}) *pairs()*
Returns three values: the |next()| function, the table {t}, and `nil`,
so that the construction
`for k,v in pairs(t) do` `body` `end`
will iterate over all key-value pairs of table {t}.
pcall({f}, {arg1}, {...})