string.byte()

string.byte (s [, i [, j]])s[i]s[i+1]s[j]ijistring.sub Numeric codes are not necessarily portable across platforms.

print()

print (···)stdouttostringprintstring.formatio.write

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.

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.

assert()

assert (v [, message]) Calls error if the value of its argument v is false (i.e., nil or false); otherwise, returns all its arguments. In case of error, message is the error object; when absent, it defaults to "assertion failed!"

Format Strings for Pack and Unpack

6.4.2 – Format Strings for Pack and Unpack The first argument to string.pack, string.packsize, and string.unpack is a format string, which describes the layout of the structure being created or read. A format string is a sequence of conversion options. The conversion options are as follows: <: sets little endian >: sets big endian =: sets native endian ![n]: sets maximum alignment to n (default is native alignment) b: a signed byte (char) B: an unsigned byte (char) h: a signed

Assignment

3.3.3 – Assignment Lua allows multiple assignments. Therefore, the syntax for assignment defines a list of variables on the left side and a list of expressions on the right side. The elements in both lists are separated by commas: stat ::= varlist ‘=’ explist varlist ::= var {‘,’ var} explist ::= exp {‘,’ exp} Expressions are discussed in §3.4. Before the assignment, the list of values is adjusted to the length of the list of variables. If there are more values than needed, the excess valu

lua_insert

lua_insert[-1, +1, –] void lua_insert (lua_State *L, int index); Moves the top element into the given valid index, shifting up the elements above this index to open space. This function cannot be called with a pseudo-index, because a pseudo-index is not an actual stack position.

lua_seti

lua_seti[-1, +0, e] void lua_seti (lua_State *L, int index, lua_Integer n); Does the equivalent to t[n] = v, where t is the value at the given index and v is the value at the top of the stack. This function pops the value from the stack. As in Lua, this function may trigger a metamethod for the "newindex" event (see §2.4).

lua_Alloc

lua_Alloc typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); The type of the memory-allocation function used by Lua states. The allocator function must provide a functionality similar to realloc, but not exactly the same. Its arguments are ud, an opaque pointer passed to lua_newstate; ptr, a pointer to the block being allocated/reallocated/freed; osize, the original size of the b