string.sub()

string.sub (s, i [, j])sijijjstring.sub(s,1,j)sjstring.sub(s, -i)isi If, after the translation of negative indices, i is less than 1, it is corrected to 1. If j is greater than the string length, it is corrected to that length. If, after these corrections, i is greater than j, the function returns the empty string.

utf8.offset()

utf8.offset (s, n [, i])nsiniin#s + 1utf8.offset(s, -n)nnil As a special case, when n is 0 the function returns the start of the encoding of the character that contains the i-th byte of s. This function assumes that s is a valid UTF-8 string.

luaL_callmeta

luaL_callmeta[-0, +(0|1), e] int luaL_callmeta (lua_State *L, int obj, const char *e); Calls a metamethod. If the object at index obj has a metatable and this metatable has a field e, this function calls this field passing the object as its only argument. In this case this function returns true and pushes onto the stack the value returned by the call. If there is no metatable or no metamethod, this function returns false (without pushing any value on the stack).

luaL_Buffer

luaL_Buffer typedef struct luaL_Buffer luaL_Buffer; Type for a string buffer. A string buffer allows C code to build Lua strings piecemeal. Its pattern of use is as follows: First declare a variable b of type luaL_Buffer. Then initialize it with a call luaL_buffinit(L, &b). Then add string pieces to the buffer calling any of the luaL_add* functions. Finish by calling luaL_pushresult(&b). This call leaves the final string on the top of the stack. If you know beforehand the to

debug.sethook()

debug.sethook ([thread,] hook, mask [, count]) Sets the given function as a hook. The string mask and the number count describe when the hook will be called. The string mask may have any combination of the following characters, with the given meaning: 'c': the hook is called every time Lua calls a function; 'r': the hook is called every time Lua returns from a function; 'l': the hook is called every time Lua enters a new line of code. Moreover, with a count different from zero, the

math.cos()

math.cos (x) Returns the cosine of x (assumed to be in radians).

lua_pushglobaltable

lua_pushglobaltable[-0, +1, –] void lua_pushglobaltable (lua_State *L); Pushes the global environment onto the stack.

lua_gettable

lua_gettable[-1, +1, e] int lua_gettable (lua_State *L, int index); Pushes onto the stack the value t[k], where t is the value at the given index and k is the value at the top of the stack. This function pops the key from the stack, pushing the resulting value in its place. As in Lua, this function may trigger a metamethod for the "index" event (see §2.4). Returns the type of the pushed value.

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

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