functions are
declared in `lualib.h` and should not be called directly: you must call them
like any other Lua C function, e.g., by using `lua_call` (see |lua_call()|).
==============================================================================
5.1 Basic Functions *lua-lib-core*
The basic library provides some 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.
assert({v} [, {message}]) *assert()*
Issues an error when the value of its argument `v` is false (i.e., `nil` or
`false`); otherwise, returns all its arguments. `message` is an error message;
when absent, it defaults to "assertion failed!"
collectgarbage({opt} [, {arg}]) *collectgarbage()*
This function is a generic interface to the garbage collector. It
performs different functions according to its first argument, {opt}:
`"stop"` stops the garbage collector.
`"restart"` restarts the garbage collector.
`"collect"` performs a full garbage-collection cycle.
`"count"` returns the total memory in use by Lua (in Kbytes).
`"step"` performs a garbage-collection step. The step "size" is
controlled by {arg} (larger values mean more steps) in a
non-specified way. If you want to control the step size
you must experimentally tune the value of {arg}. Returns
`true` if the step finished a collection cycle.
`"setpause"` sets {arg} /100 as the new value for the `pause` of
the collector (see |lua-gc|).
`"setstepmul"` sets {arg} /100 as the new value for the
`step multiplier` of the collector (see |lua-gc|).
dofile({filename}) *dofile()*
Opens the named file and executes its contents as a Lua chunk. When
called without arguments, `dofile` executes the contents of the
standard input (`stdin`). Returns all values returned by the chunk. In
case of errors, `dofile` propagates the error to its caller (that is,
`dofile` does not run in protected mode).
error({message} [, {level}]) *error()*
Terminates the last protected function called and returns `message` as
the error message. Function {error} never returns.
Usually, {error} adds some information about the error position at the
beginning of the message. The {level} argument specifies how to get
the error position. With level 1 (the default), the error position is
where the {error} function was called. Level 2 points the error to
where the function that called {error} was called; and so on. Passing
a level 0 avoids the addition of error 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"`