pcall()

pcall (f [, arg1, ···]) Calls function f with the given arguments in protected mode. This means that any error inside f is not propagated; instead, pcall catches the error and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case, pcall also returns all results from the call, after this first result. In case of any error, pcall returns false plus the error message.

load()

load (chunk [, chunkname [, mode [, env]]]) Loads a chunk. If chunk is a string, the chunk is this string. If chunk is a function, load calls it repeatedly to get the chunk pieces. Each call to chunk must return a string that concatenates with previous results. A return of an empty string, nil, or no value signals the end of the chunk. If there are no syntactic errors, returns the compiled chunk as a function; otherwise, returns nil plus the error message. If the resulting function has

lua_touserdata

lua_touserdata[-0, +0, –] void *lua_touserdata (lua_State *L, int index); If the value at the given index is a full userdata, returns its block address. If the value is a light userdata, returns its pointer. Otherwise, returns NULL.

lua_compare

lua_compare[-0, +0, e] int lua_compare (lua_State *L, int index1, int index2, int op); Compares two Lua values. Returns 1 if the value at index index1 satisfies op when compared with the value at index index2, following the semantics of the corresponding Lua operator (that is, it may call metamethods). Otherwise returns 0. Also returns 0 if any of the indices is not valid. The value of op must be one of the following constants: LUA_OPEQ: compares for equality (==) LUA_OPLT: compares f

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

math.modf()

math.modf (x) Returns the integral part of x and the fractional part of x. Its second result is always a float.

math.randomseed()

math.randomseed (x) Sets x as the "seed" for the pseudo-random generator: equal seeds produce equal sequences of numbers.

lua_status

lua_status[-0, +0, –] int lua_status (lua_State *L); Returns the status of the thread L. The status can be 0 (LUA_OK) for a normal thread, an error code if the thread finished the execution of a lua_resume with an error, or LUA_YIELD if the thread is suspended. You can only call functions in threads with status LUA_OK. You can resume threads with status LUA_OK (to start a new coroutine) or LUA_YIELD (to resume a coroutine).

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

table.sort()

table.sort (list [, comp]) Sorts list elements in a given order, in-place, from list[1] to list[#list]. If comp is given, then it must be a function that receives two list elements and returns true when the first element must come before the second in the final order (so that, after the sort, i < j implies not comp(list[j],list[i])). If comp is not given, then the standard Lua operator < is used instead. Note that the comp function must define a strict partial order over the elements