_G

_G§2.2

lua_CFunction

lua_CFunction typedef int (*lua_CFunction) (lua_State *L); Type for C functions. In order to communicate properly with Lua, a C function must use the following protocol, which defines the way parameters and results are passed: a C function receives its arguments from Lua in its stack in direct order (the first argument is pushed first). So, when the function starts, lua_gettop(L) returns the number of arguments received by the function. The first argument (if any) is at index 1 and its last

package.loadlib()

package.loadlib (libname, funcname) Dynamically links the host program with the C library libname. If funcname is "*", then it only links with the library, making the symbols exported by the library available to other dynamically linked libraries. Otherwise, it looks for a function funcname inside the library and returns this function as a C function. So, funcname must follow the lua_CFunction prototype (see lua_CFunction). This is a low-level function. It completely bypasses the package

lua_insert

lua_insert[-1, +1, –] void lua_insert (lua_State *L, int index); Moves the top element into the given valid index, shifting up the elements above this index to open space. This function cannot be called with a pseudo-index, because a pseudo-index is not an actual stack position.

lua_gethook

lua_gethook[-0, +0, –] lua_Hook lua_gethook (lua_State *L); Returns the current hook function.

package.searchers

package.searchers A table used by require to control how to load modules. Each entry in this table is a searcher function. When looking for a module, require calls each of these searchers in ascending order, with the module name (the argument given to require) as its sole parameter. The function can return another function (the module loader) plus an extra value that will be passed to that loader, or a string explaining why it did not find that module (or nil if it has nothing to say). Lu

os.date()

os.date ([format [, time]]) Returns a string or a table containing date and time, formatted according to the given string format. If the time argument is present, this is the time to be formatted (see the os.time function for a description of this value). Otherwise, date formats the current time. If format starts with '!', then the date is formatted in Coordinated Universal Time. After this optional character, if format is the string "*t", then date returns a table with the following fiel

lua_Reader

lua_Reader typedef const char * (*lua_Reader) (lua_State *L, void *data, size_t *size); The reader function used by lua_load. Every time it needs another piece of the chunk, lua_load calls the reader, passing along its data parameter. The reader must return a pointer to a block of memory with a new piece of the chunk and set size to the block size. The block must exist until the reader function is called again. To signal

luaL_checkversion

luaL_checkversion[-0, +0, v] void luaL_checkversion (lua_State *L); Checks whether the core running the call, the core that created the Lua state, and the code making the call are all using the same version of Lua. Also checks whether the core running the call and the core that created the Lua state are using the same address space.

Weak Tables

2.5.2 – Weak Tables A weak table is a table whose elements are weak references. A weak reference is ignored by the garbage collector. In other words, if the only references to an object are weak references, then the garbage collector will collect that object. A weak table can have weak keys, weak values, or both. A table with weak values allows the collection of its values, but prevents the collection of its keys. A table with both weak keys and weak values allows the collection of both keys