lua_close

lua_close[-0, +0, –] void lua_close (lua_State *L); Destroys all objects in the given Lua state (calling the corresponding garbage-collection metamethods, if any) and frees all dynamic memory used by this state. On several platforms, you may not need to call this function, because all resources are naturally released when the host program ends. On the other hand, long-running programs that create multiple states, such as daemons or web servers, will probably need to close states as soon as t

Bitwise Operators

3.4.2 – Bitwise Operators Lua supports the following bitwise operators: &: bitwise AND |: bitwise OR ~: bitwise exclusive OR >>: right shift <<: left shift ~: unary bitwise NOT All bitwise operations convert its operands to integers (see §3.4.3), operate on all bits of those integers, and result in an integer. Both right and left shifts fill the vacant bits with zeros. Negative displacements shift to the other direction; displacements with absolute values equal to o

math.ult()

math.ult (m, n) Returns a boolean, true if and only if integer m is below integer n when they are compared as unsigned integers.

lua_Unsigned

lua_Unsigned typedef ... lua_Unsigned; The unsigned version of lua_Integer.

lua_newstate

lua_newstate[-0, +0, –] lua_State *lua_newstate (lua_Alloc f, void *ud); Creates a new thread running in a new, independent state. Returns NULL if it cannot create the thread or the state (due to lack of memory). The argument f is the allocator function; Lua does all memory allocation for this state through this function (see lua_Alloc). The second argument, ud, is an opaque pointer that Lua passes to the allocator in every call.

luaL_setfuncs

luaL_setfuncs[-nup, +0, m] void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup); Registers all functions in the array l (see luaL_Reg) into the table on the top of the stack (below optional upvalues, see next). When nup is not zero, all functions are created sharing nup upvalues, which must be previously pushed on the stack on top of the library table. These values are popped from the stack after the registration.

lua_pushcclosure

lua_pushcclosure[-n, +1, m] void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n); Pushes a new C closure onto the stack. When a C function is created, it is possible to associate some values with it, thus creating a C closure (see §4.4); these values are then accessible to the function whenever it is called. To associate values with a C function, first these values must be pushed onto the stack (when there are multiple values, the first value is pushed first). Then lua_pushcclosur

lua_getuservalue

lua_getuservalue[-0, +1, –] int lua_getuservalue (lua_State *L, int index); Pushes onto the stack the Lua value associated with the full userdata at the given index. Returns the type of the pushed value.

lua_load

lua_load[-0, +1, –] int lua_load (lua_State *L, lua_Reader reader, void *data, const char *chunkname, const char *mode); Loads a Lua chunk without running it. If there are no errors, lua_load pushes the compiled chunk as a Lua function on top of the stack. Otherwise, it pushes an error message. The return values of lua_load are: LUA_OK: no errors; LUA_ERRSYNTAX: syntax error during precompilation; LUA_ERRMEM: memory allocation

lua_Number

lua_Number typedef ... lua_Number; The type of floats in Lua. By default this type is double, but that can be changed to a single float or a long double. (See LUA_FLOAT_TYPE in luaconf.h.)