lua_numbertointeger

lua_numbertointeger int lua_numbertointeger (lua_Number n, lua_Integer *p); Converts a Lua float to a Lua integer. This macro assumes that n has an integral value. If that value is within the range of Lua integers, it is converted to an integer and assigned to *p. The macro results in a boolean indicating whether the conversion was successful. (Note that this range test can be tricky to do correctly without this macro, due to roundings.) This macro may evaluate its arguments more than once.

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.)

lua_next

lua_next[-1, +(2|0), e] int lua_next (lua_State *L, int index); Pops a key from the stack, and pushes a key–value pair from the table at the given index (the "next" pair after the given key). If there are no more elements in the table, then lua_next returns 0 (and pushes nothing). A typical traversal looks like this: /* table is in the stack at index 't' */ lua_pushnil(L); /* first key */ while (lua_next(L, t) != 0) { /* uses 'key' (at index -2) and 'value' (at index -1) */ printf("%

lua_newuserdata

lua_newuserdata[-0, +1, m] void *lua_newuserdata (lua_State *L, size_t size); This function allocates a new block of memory with the given size, pushes onto the stack a new full userdata with the block address, and returns this address. The host program can freely use this memory.

lua_newthread

lua_newthread[-0, +1, m] lua_State *lua_newthread (lua_State *L); Creates a new thread, pushes it on the stack, and returns a pointer to a lua_State that represents this new thread. The new thread returned by this function shares with the original thread its global environment, but has an independent execution stack. There is no explicit function to close or to destroy a thread. Threads are subject to garbage collection, like any Lua object.

lua_newtable

lua_newtable[-0, +1, m] void lua_newtable (lua_State *L); Creates a new empty table and pushes it onto the stack. It is equivalent to lua_createtable(L, 0, 0).

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.

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_len

lua_len[-0, +1, e] void lua_len (lua_State *L, int index); Returns the length of the value at the given index. It is equivalent to the '#' operator in Lua (see §3.4.7) and may trigger a metamethod for the "length" event (see §2.4). The result is pushed on the stack.

lua_KFunction

lua_KFunction typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx); Type for continuation functions (see §4.7).