lua_Debug

lua_Debug typedef struct lua_Debug { int event; const char *name; /* (n) */ const char *namewhat; /* (n) */ const char *what; /* (S) */ const char *source; /* (S) */ int currentline; /* (l) */ int linedefined; /* (S) */ int lastlinedefined; /* (S) */ unsigned char nups; /* (u) number of upvalues */ unsigned char nparams; /* (u) number of parameters */ char isvararg; /* (u) */ char i

Control Structures

3.3.4 – Control Structures The control structures if, while, and repeat have the usual meaning and familiar syntax: stat ::= while exp do block end stat ::= repeat block until exp stat ::= if exp then block {elseif exp then block} [else block] end Lua also has a for statement, in two flavors (see §3.3.5). The condition expression of a control structure can return any value. Both false and nil are considered false. All values different from nil and false are considered true (in particular,

file:setvbuf()

file:setvbuf (mode [, size]) Sets the buffering mode for an output file. There are three available modes: "no": no buffering; the result of any output operation appears immediately. "full": full buffering; output operation is performed only when the buffer is full or when you explicitly flush the file (see io.flush). "line": line buffering; output is buffered until a newline is output or there is any input from some special files (such as a terminal device). For the last two case

os.setlocale()

os.setlocale (locale [, category]) Sets the current locale of the program. locale is a system-dependent string specifying a locale; category is an optional string describing which category to change: "all", "collate", "ctype", "monetary", "numeric", or "time"; the default category is "all". The function returns the name of the new locale, or nil if the request cannot be honored. If locale is the empty string, the current locale is set to an implementation-defined native locale. If locale is

coroutine.yield()

coroutine.yield (···) Suspends the execution of the calling coroutine. Any arguments to yield are passed as extra results to resume.

lua_yieldk

lua_yieldk[-?, +?, e] int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k); Yields a coroutine (thread). When a C function calls lua_yieldk, the running coroutine suspends its execution, and the call to lua_resume that started this coroutine returns. The parameter nresults is the number of values from the stack that will be passed as results to lua_resume. When the coroutine is resumed again, Lua calls the given co

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

string.format()

string.format (formatstring, ···) Returns a formatted version of its variable number of arguments following the description given in its first argument (which must be a string). The format string follows the same rules as the ISO C function sprintf. The only differences are that the options/modifiers *, h, L, l, n, and p are not supported and that there is an extra option, q. The q option formats a string between double quotes, using escape sequences when necessary to ensure that it can saf

lua_pcall

lua_pcall[-(nargs + 1), +(nresults|1), –] int lua_pcall (lua_State *L, int nargs, int nresults, int msgh); Calls a function in protected mode. Both nargs and nresults have the same meaning as in lua_call. If there are no errors during the call, lua_pcall behaves exactly like lua_call. However, if there is any error, lua_pcall catches it, pushes a single value on the stack (the error object), and returns an error code. Like lua_call, lua_pcall always removes the function and its arguments f

The Length Operator

3.4.7 – The Length Operator The length operator is denoted by the unary prefix operator #. The length of a string is its number of bytes (that is, the usual meaning of string length when each character is one byte). The length operator applied on a table returns a border in that table. A border in a table t is any natural number that satisfies the following condition: (border == 0 or t[border] ~= nil) and t[border + 1] == nil In words, a border is any (natural) index in a table where a n