API reference

green Lus stable functions
red Lus unstable functions
blue Lua functions
gray Lua functions removed in Lus
yellow Lua functions deprecated in Lus

Environment

Generic

_G _VERSION assert collectgarbage dofile error fromcsv fromjson getmetatable ipairs load loadfile next pairs pcall pledge print rawequal rawget rawlen rawset require select setmetatable tocsv tojson tonumber tostring type warn xpcall

Coroutine

coroutine.close coroutine.create coroutine.isyieldable coroutine.resume coroutine.running coroutine.status coroutine.wrap coroutine.yield

Debug

debug.debug debug.gethook debug.getinfo debug.getlocal debug.getmetatable debug.getregistry debug.getupvalue debug.getuservalue debug.parse debug.sethook debug.setlocal debug.setmetatable debug.setupvalue debug.setuservalue debug.traceback debug.upvalueid debug.upvaluejoin

Filesystem

fs.copy fs.createdirectory fs.createlink fs.follow fs.move fs.list fs.remove fs.type

fs.path.delimiter fs.path.join fs.path.name fs.path.parent fs.path.separator fs.path.split

IO

io.close io.flush io.input io.lines io.open io.output io.popen io.read io.stderr io.stdin io.stdout io.tmpfile io.type io.write file:close file:flush file:lines file:read file:seek file:setvbuf file:write

Table

table.clone table.concat table.create table.filter table.groupby table.insert table.map table.mean table.median table.move table.pack table.reduce table.remove table.reshape table.sort table.sortby table.stdev table.sum table.transpose table.unpack table.unzip table.zip


Math

math.abs math.acos math.asin math.atan math.ceil math.cos math.deg math.exp math.floor math.fmod math.frexp math.huge math.ldexp math.log math.max math.maxinteger math.min math.mininteger math.modf math.pi math.rad math.random math.randomseed math.sin math.sqrt math.tan math.tointeger math.type math.ult

Network

network.fetch network.tcp.bind network.tcp.connect network.udp.open server:accept server:close server:settimeout socket:close socket:receive socket:send socket:settimeout udp:close udp:receive udp:sendto

Worker

worker.create worker.status worker.receive worker.send worker.message worker.peek

OS

os.clock os.date os.difftime os.execute os.exit os.getenv os.remove os.rename os.platform os.setlocale os.time os.tmpname

Package

package.config package.cpath package.loaded package.loadlib package.path package.preload package.searchers package.searchpath

String

string.byte string.char string.dump string.find string.format string.gmatch string.gsub string.join string.len string.lower string.ltrim string.match string.pack string.packsize string.rep string.reverse string.rtrim string.split string.sub string.transcode string.trim string.unpack string.upper

Vector

vector.create vector.pack vector.unpack vector.clone vector.size vector.resize vector.unpackmany

Compression

vector.archive.brotli.compress vector.archive.brotli.decompress vector.archive.deflate.compress vector.archive.deflate.decompress vector.archive.gzip.compress vector.archive.gzip.decompress vector.archive.lz4.compress vector.archive.lz4.decompress vector.archive.lz4.decompress_hc vector.archive.zstd.compress vector.archive.zstd.decompress

UTF-8

utf8.char utf8.charpattern utf8.codepoint utf8.codes utf8.len utf8.offset

Metamethods

__add __band __bnot __bor __bxor __call __close __concat __div __eq __gc __idiv __index __json __le __len __lt __metatable __mod __mode __mul __name __newindex __pairs __pow __shl __shr __slice __sub __tostring __unm

Environment variables

LUA_CPATH LUA_CPATH_5_5 LUA_INIT LUA_INIT_5_5 LUA_PATH LUA_PATH_5_5

C API

Main library

lua_Alloc lua_CFunction lua_Debug lua_Hook lua_Integer lua_KContext lua_KFunction lua_Number lua_Reader lua_State lua_Unsigned lua_WarnFunction lua_Writer

lua_absindex lua_arith lua_atpanic lua_call lua_callk lua_checkstack lua_close lua_closeslot lua_closethread lua_compare lua_concat lua_copy lua_createtable lua_dump lua_error lua_gc lua_getallocf lua_getextraspace lua_getfield lua_getglobal lua_gethook lua_gethookcount lua_gethookmask lua_geti lua_getinfo lua_getiuservalue lua_getlocal lua_getmetatable lua_getstack lua_gettable lua_gettop lua_getupvalue lua_insert lua_isboolean lua_iscfunction lua_isenum lua_isfunction lua_isinteger lua_islightuserdata lua_isnil lua_isnone lua_isnoneornil lua_isnumber lua_isstring lua_istable lua_isthread lua_isuserdata lua_isvector lua_isyieldable lua_len lua_load lua_newstate lua_newtable lua_newthread lua_newuserdatauv lua_next lua_numbertocstring lua_numbertointeger lua_pcall lua_pcallk lua_pop lua_pushboolean lua_pushcclosure lua_pushcfunction lua_pushenum lua_pushexternalstring lua_pushfstring lua_pushglobaltable lua_pushinteger lua_pushlightuserdata lua_pushliteral lua_pushlstring lua_pushnil lua_pushnumber lua_pushstring lua_pushthread lua_pushvalue lua_pushvfstring lua_rawequal lua_rawget lua_rawgeti lua_rawgetp lua_rawlen lua_rawset lua_rawseti lua_rawsetp lua_register lua_remove lua_replace lua_resume lua_rotate lua_setallocf lua_setfield lua_setglobal lua_sethook lua_seti lua_setiuservalue lua_setlocal lua_setmetatable lua_settable lua_settop lua_setupvalue lua_setwarnf lua_status lua_stringtonumber lua_toboolean lua_tocfunction lua_toclose lua_toenumidx lua_tointeger lua_tointegerx lua_tolstring lua_tonumber lua_tonumberx lua_topointer lua_tostring lua_tothread lua_touserdata lua_type lua_typename lua_upvalueid lua_upvalueindex lua_upvaluejoin lua_version lua_warning lua_xmove lua_yield lua_yieldk


Auxiliary library

luaL_Buffer luaL_Reg luaL_Stream

luaL_addchar luaL_addgsub luaL_addlstring luaL_addsize luaL_addstring luaL_addvalue luaL_alloc luaL_argcheck luaL_argerror luaL_argexpected luaL_buffaddr luaL_buffinit luaL_buffinitsize luaL_bufflen luaL_buffsub luaL_callmeta luaL_checkany luaL_checkinteger luaL_checklstring luaL_checknumber luaL_checkoption luaL_checkstack luaL_checkstring luaL_checktype luaL_checkudata luaL_checkversion luaL_dofile luaL_dostring luaL_error luaL_execresult luaL_fileresult luaL_getmetafield luaL_getmetatable luaL_getsubtable luaL_gsub luaL_len luaL_loadbuffer luaL_loadbufferx luaL_loadfile luaL_loadfilex luaL_loadstring luaL_makeseed luaL_newlib luaL_newlibtable luaL_newmetatable luaL_newstate luaL_openlibs luaL_openselectedlibs luaL_opt luaL_optinteger luaL_optlstring luaL_optnumber luaL_optstring luaL_prepbuffer luaL_prepbuffsize luaL_pushfail luaL_pushresult luaL_pushresultsize luaL_ref luaL_requiref luaL_setfuncs luaL_setmetatable luaL_testudata luaL_tolstring luaL_traceback luaL_typeerror luaL_typename luaL_unref luaL_where

Library openers

luaopen_base luaopen_coroutine luaopen_debug luaopen_io luaopen_math luaopen_os luaopen_package luaopen_string luaopen_table luaopen_utf8 luaopen_fs luaopen_json luaopen_network luaopen_vector luaopen_worker

Worker System

lus_WorkerSetup lus_onworker lus_worker_pool_init lus_worker_pool_shutdown

Permission System

lus_PledgeRequest lus_PledgeGranter LUS_PLEDGE_GRANT lus_initpledge lus_nextpledge lus_setpledge lus_pledge lus_haspledge lus_registerpledge lus_rejectpledge lus_rejectrequest lus_pledgeerror lus_revokepledge lus_issealed lus_checkfsperm

Constants

LUA_ERRERR LUA_ERRFILE LUA_ERRMEM LUA_ERRRUN LUA_ERRSYNTAX LUA_HOOKCALL LUA_HOOKCOUNT LUA_HOOKLINE LUA_HOOKRET LUA_HOOKTAILCALL LUA_LOADED_TABLE LUA_MASKCALL LUA_MASKCOUNT LUA_MASKLINE LUA_MASKRET LUA_MAXINTEGER LUA_MININTEGER LUA_MINSTACK LUA_MULTRET LUA_NOREF LUA_OK LUA_OPADD LUA_OPBAND LUA_OPBNOT LUA_OPBOR LUA_OPBXOR LUA_OPDIV LUA_OPEQ LUA_OPIDIV LUA_OPLE LUA_OPLT LUA_OPMOD LUA_OPMUL LUA_OPPOW LUA_OPSHL LUA_OPSHR LUA_OPSUB LUA_OPUNM LUA_PRELOAD_TABLE LUA_REFNIL LUA_REGISTRYINDEX LUA_RIDX_GLOBALS LUA_RIDX_MAINTHREAD LUA_TBOOLEAN LUA_TFUNCTION LUA_TLIGHTUSERDATA LUA_TNIL LUA_TNONE LUA_TNUMBER LUA_TENUM LUA_TSTRING LUA_TTABLE LUA_TVECTOR LUA_TTHREAD LUA_TUSERDATA LUA_USE_APICHECK LUA_YIELD LUAL_BUFFERSIZE

Environment Functions

lua_G
Type: table

A global variable (not a function) that holds the global environment.

lua_VERSION
Type: string

A global variable containing the running Lus version string.

luaassert(v, [message])

Checks whether v is truthy. If so, returns all its arguments. Otherwise, raises an error with message (defaults to "assertion failed!").

luacollectgarbage([opt: string], [arg])

Controls the garbage collector. The opt argument selects the operation: "collect" (default) performs a full collection, "stop" and "restart" control the collector, "count" returns memory in use (in KB), "step" performs a collection step, "isrunning" returns whether the collector is running, "incremental" and "generational" set the GC mode, and "param" queries or sets a GC parameter.

luadofile([filename: string])

Opens and executes the contents of filename as a Lus chunk. When called without arguments, executes from standard input. Returns all values returned by the chunk. Requires load and fs:read pledges.

luaerror(message, [level: integer])

Raises an error with message as the error object. The level argument specifies where the error position points: 1 (default) is the caller, 2 is the caller’s caller, and so on. Level 0 omits position information.

unstablefromcsv(s: string, [headers: boolean], [delimiter: string])

Parses a CSV string s and returns a table of rows. Each row is a sequential table of string values. When headers is true, the first row is used as column headers and subsequent rows are returned as tables keyed by those headers. The optional delimiter defaults to ",".

lusfromjson(s: string)

Parses a JSON string s and returns the corresponding Lus value. Tables become Lus tables, JSON null becomes nil.

luagetmetatable(object)

Returns the metatable of object. If the metatable has a __metatable field, returns that value instead. Returns nil if the object has no metatable.

luaipairs(t: table)

Returns an iterator function that traverses the integer keys of t in order, from t[1] up to the first absent index. Intended for use in for loops.

luaload(chunk: string|function, [chunkname: string], [mode: string], [env: table])

Loads a chunk. If chunk is a string, the chunk is that string. If it is a function, it is called repeatedly to get the chunk pieces. Returns the compiled chunk as a function, or nil plus an error message on failure. The optional chunkname names the chunk for error messages, mode controls whether text ("t"), binary ("b"), or both ("bt", default) are allowed, and env sets the first upvalue as the chunk’s environment. Requires the load pledge.

lualoadfile([filename: string], [mode: string], [env: table])

Loads a chunk from filename (or standard input if absent) without executing it. Returns the compiled chunk as a function, or nil plus an error message on failure. See load for the meaning of mode and env. Requires load and fs:read pledges.

luapairs(t: table)

Returns an iterator function, the table t, and nil, so that the construction for k, v in pairs(t) iterates over all key—value pairs of t. If t has a __pairs metamethod, calls it with t as argument and returns its results.

luspledge(name...: string)

Grants or checks a permission. Returns true if the permission was granted, false if it was denied or the state is sealed.

The name arguments specify the permissions to grant or check.

Special permissions: "all" grants all permissions (CLI only), "seal" prevents future permission changes. The ~ prefix rejects a permission permanently.

pledge("fs")           -- grant filesystem access
pledge("fs:read=/tmp") -- grant read access to /tmp only
pledge("~network")     -- reject network permission
pledge("seal")         -- lock permissions
luaprint(...)

Prints its arguments to standard output, converting each to a string with tostring. Arguments are separated by tabs, followed by a newline.

luarawequal(v1, v2)

Checks equality of v1 and v2 without invoking the __eq metamethod. Returns true if they are primitively equal.

luarawget(t: table, k)

Gets the value of t[k] without invoking the __index metamethod.

luarawlen(v: table|string)

Returns the length of v without invoking the __len metamethod. v must be a table or string.

luarawset(t: T, k, v)

Sets t[k] = v without invoking the __newindex metamethod. Returns t.

luarequire(modname: string)

Loads and runs the module modname. Searches package.searchers in order to find a loader. Caches results in package.loaded so subsequent calls return the same value.

luaselect(index: integer|string, ...)

If index is a number, returns all arguments after argument number index. If index is the string "#", returns the total number of extra arguments.

luasetmetatable(t: T, metatable: table|nil)

Sets the metatable of table t to metatable. If metatable is nil, removes the metatable. Raises an error if the existing metatable has a __metatable field. Returns t.

unstabletocsv(t: table, [delimiter: string])

Converts a table of rows t to a CSV string. Each row must be a sequential table of values. Non-string values are converted via tostring; nil values produce empty fields. Fields containing the delimiter, newlines, or double quotes are automatically quoted. The optional delimiter defaults to ",".

lustojson(value, [filter: function])

Converts a Lus value to a JSON string. The optional filter argument controls serialization. Objects with a __json metamethod use it for custom serialization.

luatonumber(e, [base: integer])

Converts e to a number. If e is already a number, returns it. If e is a string, tries to parse it as a numeral. If e is an enum value, returns its 1-based index. The optional base (2—36) specifies the base for string conversion. Returns nil on failure.

luatostring(v)

Converts v to a human-readable string. If v has a __tostring metamethod, calls it with v as argument and returns the result.

luatype(v)

Returns the type of v as a string: "nil", "number", "string", "boolean", "table", "function", "thread", "userdata", "vector", or "enum".

luawarn(msg1: string, ...)

Emits a warning by concatenating all arguments (which must be strings) and sending the result to the warning system. Warnings beginning with "@" are control messages: "@on" enables and "@off" disables warnings.

Table Library

lustable.clone(t: T, [deep: boolean])

Creates a copy of the table t. If deep is true, nested tables are recursively cloned. Deep copies preserve circular references.

local x = table.clone(t)        -- shallow copy
local y = table.clone(t, true)  -- deep copy
luatable.concat(list: table, [sep: string], [i: integer], [j: integer])

Concatenate the string or number elements of table list, separated by sep (empty string by default), from index i to j.

luatable.create(narray: integer, [nhash: integer])

Create a new table with pre-allocated space for narray array elements and nhash hash elements. Useful for performance when the final table size is known.

unstabletable.filter(array: table, predicate: function)

Returns a new table containing only elements of array for which predicate(element) returns a truthy value. The original table is not modified. The result is a dense sequence.

unstabletable.groupby(array: table, keyfunc: function)

Groups elements of array by the result of keyfunc(element). Returns a new table where keys are the grouping results and values are tables of grouped elements.

luatable.insert(list: table, [pos: integer], [value])

Insert value at position pos in list, shifting up subsequent elements. If pos is omitted, appends to the end.

unstabletable.map(array: table, func: function)

Applies func to each element of array, returning a new table of results. The function receives (element, index) as arguments. The original table is not modified.

unstabletable.mean(array: table)

Computes the arithmetic mean of numeric values in array. Non-numeric values are skipped. Returns NaN if no numeric values exist.

unstabletable.median(array: table)

Computes the median of numeric values in array. Returns the middle value for odd-length arrays, or the average of the two middle values for even-length arrays. Non-numeric values are skipped. Does not modify the original table. Returns NaN if no numeric values exist.

luatable.move(a1: table, f: integer, e: integer, t: integer, [a2: table])

Copy elements from table a1 positions f through e into table a2 (defaults to a1) starting at position t. Returns a2.

luatable.pack(...)

Return a new table with the given arguments as array elements, plus a field "n" set to the total number of arguments.

unstabletable.reduce(array: table, func: function, [initial])

Reduces array to a single value by iteratively applying func(accumulator, element, index). If initial is not provided, the first element is used and iteration starts from the second. Raises an error if initial is not provided and the array is empty.

luatable.remove(list: table, [pos: integer])

Remove the element at position pos from list, shifting down subsequent elements. Default pos is #list, so it removes the last element. Returns the removed value.

unstabletable.reshape(array: table, rows: integer, cols: integer)

Reshapes a 1D array into a 2D matrix with the specified dimensions, filled in row-major order. The array length must equal rows * cols.

luatable.sort(list: table, [comp: function])

Sort list elements in place. If comp is given, it must be a function that takes two elements and returns true when the first is less than the second. The sort is not stable.

unstabletable.sortby(array: table, keyfunc: function, [asc: boolean])

Sorts array in-place by the key returned by keyfunc(element). When asc is false, sorts in descending order. Default is ascending. Returns nothing.

unstabletable.stdev(array: table, [sample: boolean])

Computes the standard deviation of numeric values in array. When sample is true, divides by n-1 (sample standard deviation); otherwise divides by n (population standard deviation). Non-numeric values are skipped. Returns NaN if no numeric values exist.

unstabletable.sum(array: table)

Computes the sum of numeric values in array. Non-numeric values are skipped. Returns 0 for an empty table.

unstabletable.transpose(matrix: table)

Transposes a 2D table (matrix) so that result[i][j] == matrix[j][i]. All rows must have the same length. Raises an error for non-rectangular matrices.

luatable.unpack(list: table, [i: integer], [j: integer])

Return the elements from table list from index i to j. Defaults to i = 1 and j = #list.

unstabletable.unzip(array_of_tuples: table)

Splits a table of tuples into separate tables (inverse of table.zip). Returns multiple tables, one per position in the tuples. All tuples must have the same length.

unstabletable.zip(...)

Combines multiple tables element-wise into a table of tuples. The result length equals the length of the shortest input table. Each tuple is a table {table1[i], table2[i], ...}.

String Library

luastring.byte(s: string, [i: integer], [j: integer])

Return the byte values of characters s[i] through s[j]. Defaults to i = 1 and j = i.

luastring.char(...)

Return a string of characters from the given byte values.

luastring.dump(function: function, [strip: boolean])

Return a binary string containing a serialized representation of function, so that a later load on this string returns a copy of the function. If strip is true, debug information is omitted.

luastring.find(s: string, pattern: string, [init: integer], [plain: boolean])

Look for the first match of pattern in string s. Returns the start and end indices of the match, plus any captures. Returns nil if no match is found. If init is given, the search starts at that position. If plain is true, performs a plain substring search with no pattern matching.

luastring.format(formatstring: string, ...)

Return a formatted string following the description in formatstring, which follows printf-style directives. Accepts %d, %i, %u, %f, %e, %g, %x, %o, %s, %q, %c, and %%.

luastring.gmatch(s: string, pattern: string, [init: integer])

Return an iterator function that, each time it is called, returns the next captures from pattern in string s. If pattern has no captures, the whole match is returned. If init is given, the search starts at that position.

luastring.gsub(s: string, pattern: string, repl: string|table|function, [n: integer])

Return a copy of s where all (or the first n) occurrences of pattern are replaced by repl. The replacement repl can be a string, table, or function. Also returns the total number of substitutions as a second value.

unstablestring.join(t: table, delimiter: string)

Joins elements of table t into a single string with delimiter between each element. Non-string values are converted via tostring. Empty table returns an empty string.

luastring.len(s: string)

Return the length of string s in bytes.

luastring.lower(s: string)

Return a copy of s with all uppercase letters changed to lowercase, according to the current locale.

unstablestring.ltrim(s: string, [chars: string])

Removes leading characters from string s. If chars is not provided, removes whitespace (space, tab, newline, carriage return). Otherwise removes all contiguous characters present in chars from the left.

luastring.match(s: string, pattern: string, [init: integer])

Look for the first match of pattern in string s. Returns the captures from the match, or the whole match if there are no captures. Returns nil if no match is found.

luastring.pack(fmt: string, ...)

Return a binary string containing the values packed according to format string fmt. See string.unpack for format codes.

luastring.packsize(fmt: string)

Return the size of the string that would result from string.pack with format fmt. The format must not contain variable-length options.

luastring.rep(s: string, n: integer, [sep: string])

Return a string consisting of n copies of s, separated by sep (empty string by default).

luastring.reverse(s: string)

Return a string with the bytes of s in reverse order.

unstablestring.rtrim(s: string, [chars: string])

Removes trailing characters from string s. If chars is not provided, removes whitespace (space, tab, newline, carriage return). Otherwise removes all contiguous characters present in chars from the right.

unstablestring.split(s: string, delimiter: string)

Splits string s on the literal delimiter, returning a table of substrings. An empty delimiter splits into individual characters. Consecutive delimiters produce empty string entries.

luastring.sub(s: string, i: integer, [j: integer])

Return the substring of s from position i to j (inclusive). Negative indices count from the end of the string. Default for j is -1 (end of string).

lusstring.transcode(s: string, from: string, to: string)

Transcodes string s from encoding from to encoding to. Supported encodings depend on the platform.

unstablestring.trim(s: string, [chars: string])

Removes leading and trailing characters from string s. If chars is not provided, removes whitespace (space, tab, newline, carriage return). Otherwise removes all contiguous characters present in chars from both ends.

luastring.unpack(fmt: string, s: string, [pos: integer])

Return the values packed in string s according to format fmt, starting at position pos (default 1). Also returns the position after the last read byte.

luastring.upper(s: string)

Return a copy of s with all lowercase letters changed to uppercase, according to the current locale.

Math Library

luamath.abs(x: number)

Returns the absolute value of x.

luamath.acos(x: number)

Returns the arc cosine of x in radians.

luamath.asin(x: number)

Returns the arc sine of x in radians.

luamath.atan(y: number, [x: number])

Returns the arc tangent of y/x in radians, using the signs of both arguments to determine the quadrant. x defaults to 1.

luamath.ceil(x: number)

Returns the smallest integer not less than x.

luamath.cos(x: number)

Returns the cosine of angle x (in radians).

luamath.deg(x: number)

Converts angle x from radians to degrees.

luamath.exp(x: number)

Returns e raised to the power x.

luamath.floor(x: number)

Returns the largest integer not greater than x.

luamath.fmod(x: number, y: number)

Returns the remainder of the division of x by y, rounding the quotient towards zero.

luamath.frexp(x: number)

Returns m and e such that x = m * 2^e, where m is in [0.5, 1) and e is an integer.

luamath.huge

The float value HUGE_VAL, greater than any other numeric value.

luamath.ldexp(m: number, e: integer)

Returns m * 2^e.

luamath.log(x: number, [base: number])

Returns the logarithm of x in the given base. The default base is e (natural logarithm).

luamath.max(x: number, ...)

Returns the maximum value among its arguments.

luamath.maxinteger

The maximum value for an integer.

luamath.min(x: number, ...)

Returns the minimum value among its arguments.

luamath.mininteger

The minimum value for an integer.

luamath.modf(x: number)

Returns the integral part and the fractional part of x.

luamath.pi

The value of pi.

luamath.rad(x: number)

Converts angle x from degrees to radians.

luamath.random([m: integer], [n: integer])

When called without arguments, returns a uniform pseudo-random float in [0,1). With one integer m, returns an integer in [1, m]. With two integers m and n, returns an integer in [m, n].

luamath.randomseed([x: integer], [y: integer])

Sets x as the seed for the pseudo-random generator. When called without arguments, seeds with a system-dependent value. Equal seeds produce equal sequences.

luamath.sin(x: number)

Returns the sine of angle x (in radians).

luamath.sqrt(x: number)

Returns the square root of x.

luamath.tan(x: number)

Returns the tangent of angle x (in radians).

luamath.tointeger(x: number)

Converts x to an integer if it is a number with an integer value. Returns nil if x is not an integer or not a number.

luamath.type(x)

Returns "integer" if x is an integer, "float" if it is a float, or nil if x is not a number.

luamath.ult(m: integer, n: integer)

Returns true if integer m is below integer n when compared as unsigned integers.

IO Library

luaio.close([file: file])

Closes file, or the default output file if no argument is given. Returns the status from the file close operation. For files opened with io.popen, returns the exit status.

luaio.flush()

Flushes the write buffer of the default output file.

luaio.input([file: file|string])

When called with a filename, opens that file and sets it as the default input. When called with a file handle, sets it as the default input. When called with no arguments, returns the current default input file.

luaio.lines([filename: string], ...)

Returns an iterator function that reads from filename (or the default input if absent) according to the given formats. The file is automatically closed when the iterator finishes. Default format reads lines.

luaio.open(filename: string, [mode: string])

Opens filename in the given mode and returns a file handle, or nil plus an error message on failure. Modes follow C fopen conventions: "r" (read, default), "w" (write), "a" (append), plus optional "b" for binary.

luaio.output([file: file|string])

When called with a filename, opens that file and sets it as the default output. When called with a file handle, sets it as the default output. When called with no arguments, returns the current default output file.

luaio.popen(prog: string, [mode: string])

Starts the program prog in a separated process and returns a file handle for reading or writing, depending on mode ("r" for reading, default; "w" for writing). Requires exec pledge.

luaio.read(...)

Reads from the default input file according to the given formats. Formats: "n" reads a number, "a" reads the whole file, "l" reads a line (default, strips newline), "L" reads a line keeping the newline, or an integer n reads n bytes.

luaio.stderr
Type: file

Standard error file handle.

luaio.stdin
Type: file

Standard input file handle.

luaio.stdout
Type: file

Standard output file handle.

luaio.tmpfile()

Returns a handle for a temporary file, opened in update mode. The file is automatically removed when the program ends.

luaio.type(obj)

Returns "file" if obj is an open file handle, "closed file" if it is a closed file handle, or nil if it is not a file handle.

luaio.write(...)

Writes each argument to the default output file. Arguments must be strings or numbers. Returns the file handle on success, or nil plus an error message on failure.

OS Library

luaos.clock()

Returns the CPU time used by the program, in seconds.

luaos.date([format: string], [time: integer])

Returns a string or table with the date and time, formatted according to format. If format starts with "!", uses UTC. If format is "*t", returns a table with fields year, month, day, hour, min, sec, wday, yday, isdst. The optional time argument specifies the time to format (defaults to current time).

luaos.difftime(t2: integer, t1: integer)

Returns the difference t2 - t1 in seconds, where t1 and t2 are values returned by os.time.

luaos.execute([command: string])

Passes command to the operating system shell for execution. Returns true (or nil on failure), an exit type string ("exit" or "signal"), and the exit or signal number. Requires exec pledge.

luaos.exit([code: boolean|integer], [close: boolean])

Terminates the program. The optional code argument is the exit code (true means success, false means failure, default is true). If close is true, closes the Lua state before exiting.

luaos.getenv(varname: string)

Returns the value of the environment variable varname, or nil if the variable is not defined.

lusos.platform()

Returns a string identifying the current platform (e.g., "macos", "linux", "windows").

luaos.setlocale([locale: string], [category: string])

Sets the program’s current locale. The category selects which category to set (e.g., "all", "collate", "ctype", "monetary", "numeric", "time"). If locale is nil, returns the current locale for the given category. Returns the locale name, or nil on failure.

luaos.time([t: table])

Returns the current time as a number (seconds since epoch) when called without arguments. When called with a table argument t, returns the time represented by that table (with fields year, month, day, hour, min, sec).

luaos.tmpname()

Returns a temporary file name suitable for use as a temporary file.

Debug Library

luadebug.debug()

Enters interactive debugging mode. Prompts for commands from standard input. Not available in all environments.

lusdebug.format(source: string, [chunkname: string], [indent_width: integer])

Formats Lus source code. Returns the formatted source string.

The optional chunkname specifies the name used in error messages. The optional indent_width sets the indentation width (defaults to 2).

luadebug.gethook([thread: thread])

Returns the current hook function, hook mask (a string), and hook count for the given thread (or the current thread).

luadebug.getinfo(f: function|integer, [what: string])

Returns a table with information about a function or stack level. The what string selects which fields to fill: "n" (name), "S" (source), "l" (line), "t" (tail call), "u" (upvalues), "f" (function), "L" (valid lines). Default is all.

luadebug.getlocal(f: function|integer, [local_: integer])

Returns the name and value of local variable local at stack level f. Returns nil if there is no local variable with that index. Negative indices access vararg arguments.

luadebug.getmetatable(value)

Returns the metatable of value without checking __metatable.

luadebug.getregistry()

Returns the registry table.

luadebug.getupvalue(f: function, up: integer)

Returns the name and value of upvalue up of function f. Returns nil for invalid indices.

luadebug.getuservalue(u: userdata, [n: integer])

Returns the n-th user value associated with userdata u, plus a boolean indicating whether the userdata has that value.

lusdebug.parse(code: string, [chunkname: string], [options: table])

Parses a Lus source string and returns its AST (Abstract Syntax Tree) as a nested table structure. Returns nil if parsing fails.

The optional chunkname argument specifies the name used in error messages (defaults to "=(parse)").

local ast = debug.parse("local x = 1 + 2")
-- Returns: {type = "chunk", line = 1, children = {...}}

Each AST node is a table with at minimum type (node type string) and line (source line number).

luadebug.sethook(hook: function, mask: string, [count: integer])

Sets the given function as a debug hook. The mask string may contain "c" (call), "r" (return), "l" (line). The count argument sets a count hook. Call with no arguments to remove the hook.

luadebug.setlocal(level: integer, local_: integer, value)

Sets the value of local variable local at stack level level to value. Returns the variable name, or nil if the index is invalid.

luadebug.setmetatable(value, t: table|nil)

Sets the metatable of value to t (which can be nil). Returns value.

luadebug.setupvalue(f: function, up: integer, value)

Sets the value of upvalue up of function f to value. Returns the upvalue name, or nil for invalid indices.

luadebug.setuservalue(u: userdata, value, [n: integer])

Sets the n-th user value associated with userdata u to value. Returns u.

luadebug.traceback([message], [level: integer])

Returns a traceback string of the call stack. The optional message is prepended. The level argument specifies where to start the traceback (default 1).

luadebug.upvalueid(f: function, n: integer)

Returns a unique identifier (light userdata) for upvalue n of function f. This can be used to check whether different closures share upvalues.

luadebug.upvaluejoin(f1: function, n1: integer, f2: function, n2: integer)

Makes upvalue n1 of closure f1 refer to the same upvalue as n2 of closure f2.

Coroutine Library

luacoroutine.close(co: thread)

Closes coroutine co, putting it in a dead state. If the coroutine was suspended with pending to-be-closed variables, those variables are closed. Returns true on success, or false plus an error message if closing a variable raises an error.

luacoroutine.create(f: function)

Creates a new coroutine from function f and returns it. Does not start execution; use coroutine.resume to begin.

luacoroutine.isyieldable()

Returns true if the running coroutine can yield. A coroutine is not yieldable when it is the main thread or inside a non-yieldable C function.

luacoroutine.resume(co: thread, ...)

Starts or resumes execution of coroutine co. On the first resume, the extra arguments are passed to the coroutine body function. On subsequent resumes, the extra arguments become the results of the yield that suspended the coroutine. Returns true plus any values passed to yield or returned by the body, or false plus an error message on failure.

luacoroutine.running()

Returns the running coroutine and a boolean. The boolean is true if the running coroutine is the main thread.

luacoroutine.status(co: thread)

Returns the status of coroutine co as a string: "running", "suspended", "normal", or "dead".

luacoroutine.wrap(f: function)

Creates a coroutine from function f and returns a function that resumes it each time it is called. Arguments to the wrapper are passed as extra arguments to resume. Returns the values passed to yield, excluding the first boolean. Raises an error on failure (unlike resume).

luacoroutine.yield(...)

Suspends the running coroutine. Arguments to yield become the extra return values of the resume that restarted this coroutine.

Package Library

luapackage.config
Type: string

A string describing some compile-time configurations for packages.

luapackage.cpath
Type: string

The path used by require to search for a C loader.

luapackage.loaded
Type: table

A table used by require to control which modules are already loaded.

luapackage.loadlib(libname: string, funcname: string)

Dynamically loads C library libname. If funcname is "*", links the library globally. Otherwise, returns the C function funcname from the library. Returns nil plus an error message on failure.

luapackage.path
Type: string

The path used by require to search for a Lus loader.

luapackage.preload
Type: table

A table to store loaders for specific modules.

luapackage.searchers
Type: table

A table holding the sequence of searcher functions used by require.

luapackage.searchpath(name: string, path: string, [sep: string], [rep: string])

Searches for name in the given path string, replacing each "?" with name (with "." replaced by sep). Returns the first file that exists, or nil plus a string listing all files tried.

UTF-8 Library

luautf8.char(...)

Return a string containing the UTF-8 encoding of the given codepoints.

luautf8.charpattern

The pattern which matches exactly one UTF-8 byte sequence.

luautf8.codepoint(s: string, [i: integer], [j: integer])

Return the codepoints of all characters in s from position i to j (default i = 1, j = i).

luautf8.codes(s: string)

Return an iterator function that traverses s, returning the byte position and codepoint of each UTF-8 character.

luautf8.len(s: string, [i: integer], [j: integer])

Return the number of UTF-8 characters in s from position i to j. Returns nil plus the position of the first invalid byte on failure.

luautf8.offset(s: string, n: integer, [i: integer])

Return the byte position of the n-th UTF-8 character, counting from byte position i (default 1 for positive n, #s + 1 for non-positive).

Filesystem Library

lusfs.copy(source: string, dest: string)

Copies the file at source to dest. Returns true on success, or nil plus an error message on failure. Requires fs:read and fs:write pledges.

lusfs.createdirectory(path: string)

Creates a directory at path. Returns true on success, or nil plus an error message on failure. Requires fs:write pledge.

lusfs.createlink(target: string, link: string)

Creates a symbolic link at link pointing to target. Returns true on success, or nil plus an error message on failure. Requires fs:write pledge.

lusfs.follow(path: string)

Resolves a symbolic link at path and returns the target path. Returns nil plus an error message on failure. Requires fs:read pledge.

lusfs.list(path: string)

Returns a table of filenames in the directory at path. Returns nil plus an error message on failure. Requires fs:read pledge.

lusfs.move(source: string, dest: string)

Moves (renames) the file or directory at source to dest. Returns true on success, or nil plus an error message on failure. Requires fs:write pledge.

lusfs.path

The fs.path sub-module.

lusfs.path.delimiter

The platform path list delimiter (: on POSIX, ; on Windows).

lusfs.path.join(...)

Joins path components into a single path using the platform path separator.

lusfs.path.name(path: string)

Returns the final component (filename) of path.

lusfs.path.parent(path: string)

Returns the parent directory of path, or nil if path has no parent.

lusfs.path.separator

The platform path separator (/ on POSIX, \ on Windows).

lusfs.path.split(path: string)

Splits path into a table of its components.

lusfs.remove(path: string)

Removes the file or directory at path. Returns true on success, or nil plus an error message on failure. Requires fs:write pledge.

lusfs.type(path: string)

Returns the type of the filesystem entry at path as a string: "file", "directory", "link", or nil if it does not exist. Requires fs:read pledge.

Network Library

lusnetwork.fetch(url: string, [options: table])

Performs an HTTP(S) request to url. The optional options table may specify method, headers, and body. Returns the response body as a string, plus the HTTP status code and a response headers table. Requires network pledge.

lusnetwork.tcp

The network.tcp sub-module.

lusnetwork.tcp.bind(host: string, port: integer)

Binds a TCP server to host and port. Returns a server object that can accept incoming connections. Requires network pledge.

lusnetwork.tcp.connect(host: string, port: integer)

Connects to a TCP server at host and port. Returns a connection object for reading and writing. Requires network pledge.

lusnetwork.udp

The network.udp sub-module.

lusnetwork.udp.open(host: string, port: integer)

Opens a UDP socket bound to host and port. Returns a socket object for sending and receiving datagrams. Requires network pledge.

Vector Library

lusvector.clone(v: vector)

Creates a copy of the vector v.

lusvector.create(capacity: integer, [fast: boolean])

Creates a new vector with the given capacity in bytes. If fast is true, the buffer is not zero-initialized (faster but contents are undefined).

local v = vector.create(1024)        -- zero-initialized
local v = vector.create(1024, true)  -- fast, uninitialized
lusvector.pack(v: vector, offset: integer, fmt: string, ...)

Packs values into the vector v starting at offset. Uses the same format string as string.pack.

local v = vector.create(16)
vector.pack(v, 0, "I4I4I4", 1, 2, 3)
lusvector.resize(v: vector, newsize: integer)

Resizes the vector to newsize bytes. New bytes are zero-initialized. Existing data within the new size is preserved.

lusvector.size(v: vector)

Returns the size of the vector in bytes. Equivalent to #v.

lusvector.unpack(v: vector, offset: integer, fmt: string)

Unpacks values from the vector v starting at offset. Uses the same format string as string.unpack. Returns unpacked values followed by the next offset.

local a, b, c, nextpos = vector.unpack(v, 0, "I4I4I4")
lusvector.unpackmany(v: vector, offset: integer, fmt: string, [count: integer])

Returns an iterator that repeatedly unpacks values from v using the format fmt. Optional count limits the number of iterations.

for a, b in vector.unpackmany(v, 0, "I4I4") do
  print(a, b)
end

Worker Library

lusworker.create(path: string, ...)

Spawns a new worker running the script at path. Optional varargs are serialized and can be received by the worker via worker.peek(). Returns a worker handle. Requires load and fs:read pledges.

local w = worker.create("worker.lus", "hello", 42)
-- worker can receive "hello" and 42 via worker.peek()
lusworker.message(value)

(Worker-side only) Sends value to the worker’s outbox for the parent to receive via worker.receive().

lusworker.peek()

(Worker-side only) Blocking receive from the worker’s inbox. Blocks until a message from the parent (via worker.send()) is available.

lusworker.receive(w1: worker, ...)

Blocking select-style receive from one or more workers. Blocks until at least one worker has a message. Returns one value per worker: the message if available, or nil if that worker has no message. Propagates worker errors.

local msg = worker.receive(w)
-- or multi-worker select:
local m1, m2 = worker.receive(w1, w2)
lusworker.send(w: worker, value)

Sends value to worker w’s inbox. The worker can receive it via worker.peek(). Values are deep-copied.

lusworker.status(w: worker)

Returns the status of worker w: "running" if the worker is still executing, or "dead" if it has finished or errored.

Permission System — C API

luslus_checkfsperm
int lus_checkfsperm (lua_State *L, const char *perm, const char *path)

Convenience function for filesystem permission checks. Raises an error if denied.

luslus_haspledge
int lus_haspledge (lua_State *L, const char *name, const char *value)

Checks if a permission has been granted. Returns 1 if access is allowed, 0 if denied.

luslus_initpledge
void lus_initpledge (lua_State *L, lus_PledgeRequest *p, const char *base)

Initializes a pledge request for C-side grants. This bypasses granters and is used for direct permission grants from C code.

luslus_issealed
int lus_issealed (lua_State *L)

Returns 1 if the permission state is sealed, 0 otherwise.

luslus_nextpledge
int lus_nextpledge (lua_State *L, lus_PledgeRequest *p)

Iterates through stored values for a permission. Sets p->current to the next stored value. Returns 1 if there are more values, 0 when done.

luslus_pledge
int lus_pledge (lua_State *L, const char *name, const char *value)

Grants a permission to the Lua state. Triggers the granter callback for validation. Returns 1 on success, 0 if denied or sealed.

lusLUS_PLEDGE_CHECK
Value: 2 (int)

Read-only permission check status code.

lusLUS_PLEDGE_GRANT
Value: 0 (int)

New permission request status code.

lusLUS_PLEDGE_UPDATE
Value: 1 (int)

Updating existing permission status code.

luslus_pledgeerror
void lus_pledgeerror (lua_State *L, lus_PledgeRequest *p, const char *msg)

Sets a denial error message for user-facing feedback.

luslus_PledgeGranter
typedef void (*lus_PledgeGranter)(lua_State *L, lus_PledgeRequest *p);

Callback type for permission granters. Libraries register granters to handle their own permission validation logic.

Granters should call lus_setpledge to confirm valid permissions. Unprocessed requests are automatically denied.

luslus_PledgeRequest
typedef struct lus_PledgeRequest { const char *base; const char *sub; const char *value; const char *current; int status; int count; int has_base; } lus_PledgeRequest;

Request structure passed to granter callbacks. Contains all information about the permission being granted or checked.

status indicates the operation: LUS_PLEDGE_GRANT for new grants, LUS_PLEDGE_UPDATE for updates, LUS_PLEDGE_CHECK for access checks.

luslus_registerpledge
void lus_registerpledge (lua_State *L, const char *name, lus_PledgeGranter granter)

Registers a granter callback for a permission namespace.

luslus_rejectpledge
int lus_rejectpledge (lua_State *L, const char *name)

Permanently rejects a permission by name. Returns 1 on success, 0 if sealed.

luslus_rejectrequest
void lus_rejectrequest (lua_State *L, lus_PledgeRequest *p)

Permanently rejects a permission using the request struct. Future attempts to grant this permission will fail.

luslus_revokepledge
int lus_revokepledge (lua_State *L, const char *name)

Revokes a previously granted permission. Returns 1 on success, 0 if sealed or not found.

luslus_setpledge
void lus_setpledge (lua_State *L, lus_PledgeRequest *p, const char *sub, const char *value)

Confirms or sets a pledge value. Marks the request as processed, preventing automatic denial.

Worker System — C API

luslus_onworker
void lus_onworker (lua_State *L, lus_WorkerSetup fn)

Registers a callback to be invoked when new worker states are created.

lusLUS_WORKER_BLOCKED
Value: 1 (int)

Worker status: blocked waiting for message.

luslus_worker_create
WorkerState *lus_worker_create (lua_State *L, const char *path)

Creates a new worker running the script at path.

lusLUS_WORKER_DEAD
Value: 2 (int)

Worker status: finished execution.

lusLUS_WORKER_ERROR
Value: 3 (int)

Worker status: terminated with error.

luslus_worker_pool_init
void lus_worker_pool_init (lua_State *L)

Initializes the global worker thread pool. Called automatically on first worker.create().

luslus_worker_pool_shutdown
void lus_worker_pool_shutdown (void)

Shuts down the worker thread pool. Waits for all threads to complete.

luslus_worker_receive
int lus_worker_receive (lua_State *L, WorkerState *w)

Receives a message from the worker’s outbox. Pushes the message onto the stack.

lusLUS_WORKER_RUNNING
Value: 0 (int)

Worker status: running.

luslus_worker_send
int lus_worker_send (lua_State *L, WorkerState *w, int idx)

Sends the value at stack index idx to the worker’s inbox.

luslus_worker_status
int lus_worker_status (WorkerState *w)

Returns the status of a worker (LUS_WORKER_RUNNING, LUS_WORKER_DEAD, etc.).

luslus_WorkerSetup
typedef void (*lus_WorkerSetup)(lua_State *parent, lua_State *worker);

Callback type for worker state initialization. Called when a new worker is created, allowing embedders to configure the worker’s Lua state.

Library Openers

luaLUA_COLIBK
Value: 4 (int)

Bitmask for the coroutine library.

luaLUA_DBLIBK
Value: 8 (int)

Bitmask for the debug library.

lusLUA_FSLIBK
Value: 1024 (int)

Bitmask for the fs library.

luaLUA_GLIBK
Value: 1 (int)

Bitmask for the base library.

luaLUA_IOLIBK
Value: 16 (int)

Bitmask for the io library.

luaLUA_LOADLIBK
Value: 2 (int)

Bitmask for the package library.

luaLUA_MATHLIBK
Value: 32 (int)

Bitmask for the math library.

lusLUA_NETLIBK
Value: 2048 (int)

Bitmask for the network library.

luaLUA_OSLIBK
Value: 64 (int)

Bitmask for the os library.

luaLUA_STRLIBK
Value: 128 (int)

Bitmask for the string library.

luaLUA_TABLIBK
Value: 256 (int)

Bitmask for the table library.

luaLUA_UTF8LIBK
Value: 512 (int)

Bitmask for the utf8 library.

lusLUA_VECLIBK
Value: 8192 (int)

Bitmask for the vector library.

lusLUA_WORKERLIBK
Value: 4096 (int)

Bitmask for the worker library.

lualuaL_openlibs
#define luaL_openlibs(L) luaL_openselectedlibs(L, ~0, 0)

Opens all standard libraries.

lualuaL_openselectedlibs
void luaL_openselectedlibs (lua_State *L, int load, int preload)

Opens selected standard libraries. The load and preload bitmasks control which libraries to open or preload.

lualuaopen_base
int luaopen_base (lua_State *L)

Opens the base library. Called automatically by luaL_openlibs.

lualuaopen_coroutine
int luaopen_coroutine (lua_State *L)

Opens the coroutine library. Called automatically by luaL_openlibs.

lualuaopen_debug
int luaopen_debug (lua_State *L)

Opens the debug library. Called automatically by luaL_openlibs.

lusluaopen_fs
int luaopen_fs (lua_State *L)

Opens the fs library. Called automatically by luaL_openlibs.

lualuaopen_io
int luaopen_io (lua_State *L)

Opens the io library. Called automatically by luaL_openlibs.

lusluaopen_json
int luaopen_json (lua_State *L)

Opens the json library. Called automatically by luaL_openlibs.

lualuaopen_math
int luaopen_math (lua_State *L)

Opens the math library. Called automatically by luaL_openlibs.

lusluaopen_network
int luaopen_network (lua_State *L)

Opens the network library. Called automatically by luaL_openlibs.

lualuaopen_os
int luaopen_os (lua_State *L)

Opens the os library. Called automatically by luaL_openlibs.

lualuaopen_package
int luaopen_package (lua_State *L)

Opens the package library. Called automatically by luaL_openlibs.

lualuaopen_string
int luaopen_string (lua_State *L)

Opens the string library. Called automatically by luaL_openlibs.

lualuaopen_table
int luaopen_table (lua_State *L)

Opens the table library. Called automatically by luaL_openlibs.

lualuaopen_utf8
int luaopen_utf8 (lua_State *L)

Opens the utf8 library. Called automatically by luaL_openlibs.

lusluaopen_vector
int luaopen_vector (lua_State *L)

Opens the vector library. Called automatically by luaL_openlibs.

lusluaopen_worker
int luaopen_worker (lua_State *L)

Opens the worker library. Called automatically by luaL_openlibs.

Core C API

lualua_absindex
int lua_absindex (lua_State *L, int idx)
lualua_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.

lualua_arith
void lua_arith (lua_State *L, int op)
lualua_atpanic
lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf)
lualua_call
#define lua_call(L,n,r) lua_callk(L,(n),(r),0,NULL)

Calls a function (macro for lua_callk with no continuation).

lualua_callk
void lua_callk (lua_State *L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k)
lualua_CFunction
typedef int (*lua_CFunction)(lua_State *L);

Type for C functions that can be registered with Lua.

lualua_checkstack
int lua_checkstack (lua_State *L, int n)
lualua_close
void lua_close (lua_State *L)
lualua_closeslot
void lua_closeslot (lua_State *L, int idx)
lualua_closethread
int lua_closethread (lua_State *L, lua_State *from)
lualua_compare
int lua_compare (lua_State *L, int idx1, int idx2, int op)
lualua_concat
void lua_concat (lua_State *L, int n)
lualua_copy
void lua_copy (lua_State *L, int fromidx, int toidx)
lualua_createtable
void lua_createtable (lua_State *L, int narr, int nrec)
lualua_Debug
struct lua_Debug { int event; const char *name; const char *namewhat; const char *what; const char *source; size_t srclen; int currentline; int linedefined; int lastlinedefined; unsigned char nups; unsigned char nparams; char isvararg; unsigned char extraargs; char istailcall; int ftransfer; int ntransfer; char short_src[LUA_IDSIZE]; };

A structure used to carry different pieces of information about a function or an activation record.

lualua_dump
int lua_dump (lua_State *L, lua_Writer writer, void *data, int strip)
luaLUA_ERRERR
Value: 5 (int)

Status code for an error while running the message handler.

luaLUA_ERRMEM
Value: 4 (int)

Status code for a memory allocation error.

lualua_error
int lua_error (lua_State *L)
luaLUA_ERRRUN
Value: 2 (int)

Status code for a runtime error.

luaLUA_ERRSYNTAX
Value: 3 (int)

Status code for a syntax error.

lualua_gc
int lua_gc (lua_State *L, int what, ...)
luaLUA_GCCOLLECT
Value: 2 (int)

GC option to perform a full collection cycle.

luaLUA_GCCOUNT
Value: 3 (int)

GC option to return total memory in use (Kbytes).

luaLUA_GCCOUNTB
Value: 4 (int)

GC option to return remainder of memory in use (bytes).

luaLUA_GCGEN
Value: 7 (int)

GC option to switch to generational mode.

luaLUA_GCINC
Value: 8 (int)

GC option to switch to incremental mode.

luaLUA_GCISRUNNING
Value: 6 (int)

GC option to check if the collector is running.

luaLUA_GCPARAM
Value: 9 (int)

GC option to set/get a GC parameter.

luaLUA_GCRESTART
Value: 1 (int)

GC option to restart the collector.

luaLUA_GCSTEP
Value: 5 (int)

GC option to perform an incremental step.

luaLUA_GCSTOP
Value: 0 (int)

GC option to stop the collector.

lualua_getallocf
lua_Alloc lua_getallocf (lua_State *L, void **ud)
lualua_getextraspace
#define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE))

Returns a pointer to a raw memory area associated with the given Lua state.

lualua_getfield
int lua_getfield (lua_State *L, int idx, const char *k)
lualua_getglobal
int lua_getglobal (lua_State *L, const char *name)
lualua_gethook
lua_Hook lua_gethook (lua_State *L)
lualua_gethookcount
int lua_gethookcount (lua_State *L)
lualua_gethookmask
int lua_gethookmask (lua_State *L)
lualua_geti
int lua_geti (lua_State *L, int idx, lua_Integer n)
lualua_getinfo
int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar)
lualua_getiuservalue
int lua_getiuservalue (lua_State *L, int idx, int n)
lualua_getlocal
const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n)
lualua_getmetatable
int lua_getmetatable (lua_State *L, int objindex)
lualua_getstack
int lua_getstack (lua_State *L, int level, lua_Debug *ar)
lualua_gettable
int lua_gettable (lua_State *L, int idx)
lualua_gettop
int lua_gettop (lua_State *L)
lualua_getupvalue
const char *lua_getupvalue (lua_State *L, int funcindex, int n)
lualua_getuservalue
#define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1)

Compatibility macro. Gets the first user value of a userdata.

lualua_Hook
typedef void (*lua_Hook)(lua_State *L, lua_Debug *ar);

Type for debugging hook functions.

luaLUA_HOOKCALL
Value: 0 (int)

Debug hook event for function calls.

luaLUA_HOOKCOUNT
Value: 3 (int)

Debug hook event for instruction counts.

luaLUA_HOOKLINE
Value: 2 (int)

Debug hook event for new lines.

luaLUA_HOOKRET
Value: 1 (int)

Debug hook event for function returns.

luaLUA_HOOKTAILCALL
Value: 4 (int)

Debug hook event for tail calls.

lualua_insert
#define lua_insert(L,idx) lua_rotate(L,(idx),1)

Moves the top element into the given valid index, shifting up elements above.

lualua_Integer
typedef long long lua_Integer;

The type of integers in Lua.

lualua_isboolean
#define lua_isboolean(L,n) (lua_type(L,(n)) == LUA_TBOOLEAN)

Returns 1 if the value at the given index is a boolean.

lualua_iscfunction
int lua_iscfunction (lua_State *L, int idx)
luslua_isenum
#define lua_isenum(L,n) (lua_type(L,(n)) == LUA_TENUM)

Returns 1 if the value at the given index is an enum.

lualua_isfunction
#define lua_isfunction(L,n) (lua_type(L,(n)) == LUA_TFUNCTION)

Returns 1 if the value at the given index is a function.

lualua_isinteger
int lua_isinteger (lua_State *L, int idx)
lualua_islightuserdata
#define lua_islightuserdata(L,n) (lua_type(L,(n)) == LUA_TLIGHTUSERDATA)

Returns 1 if the value at the given index is a light userdata.

lualua_isnil
#define lua_isnil(L,n) (lua_type(L,(n)) == LUA_TNIL)

Returns 1 if the value at the given index is nil.

lualua_isnone
#define lua_isnone(L,n) (lua_type(L,(n)) == LUA_TNONE)

Returns 1 if the given index is not valid.

lualua_isnoneornil
#define lua_isnoneornil(L,n) (lua_type(L,(n)) <= 0)

Returns 1 if the given index is not valid or the value is nil.

lualua_isnumber
int lua_isnumber (lua_State *L, int idx)
lualua_isstring
int lua_isstring (lua_State *L, int idx)
lualua_istable
#define lua_istable(L,n) (lua_type(L,(n)) == LUA_TTABLE)

Returns 1 if the value at the given index is a table.

lualua_isthread
#define lua_isthread(L,n) (lua_type(L,(n)) == LUA_TTHREAD)

Returns 1 if the value at the given index is a thread.

lualua_isuserdata
int lua_isuserdata (lua_State *L, int idx)
luslua_isvector
#define lua_isvector(L,n) (lua_type(L,(n)) == LUA_TVECTOR)

Returns 1 if the value at the given index is a vector.

lualua_isyieldable
int lua_isyieldable (lua_State *L)
lualua_KContext
typedef intptr_t lua_KContext;

The type for continuation-function contexts.

lualua_KFunction
typedef int (*lua_KFunction)(lua_State *L, int status, lua_KContext ctx);

Type for continuation functions.

lualua_len
void lua_len (lua_State *L, int idx)
lualua_load
int lua_load (lua_State *L, lua_Reader reader, void *dt, const char *chunkname, const char *mode)
luaLUA_MASKCALL
Value: 1 (int)

Mask for call hook events.

luaLUA_MASKCOUNT
Value: 8 (int)

Mask for count hook events.

luaLUA_MASKLINE
Value: 4 (int)

Mask for line hook events.

luaLUA_MASKRET
Value: 2 (int)

Mask for return hook events.

luaLUA_MINSTACK
Value: 20 (int)

Minimum Lua stack size guaranteed to be available.

luaLUA_MULTRET
Value: -1 (int)

Option for multiple returns in lua_call and lua_pcall.

lualua_newstate
lua_State *lua_newstate (lua_Alloc f, void *ud, unsigned seed)
lualua_newtable
#define lua_newtable(L) lua_createtable(L, 0, 0)

Creates a new empty table and pushes it onto the stack.

lualua_newthread
lua_State *lua_newthread (lua_State *L)
lualua_newuserdata
#define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1)

Compatibility macro. Creates a new userdata with one user value.

lualua_newuserdatauv
void *lua_newuserdatauv (lua_State *L, size_t sz, int nuvalue)
lualua_next
int lua_next (lua_State *L, int idx)
lualua_Number
typedef double lua_Number;

The type of floats in Lua.

lualua_numbertocstring
unsigned lua_numbertocstring (lua_State *L, int idx, char *buff)
luaLUA_NUMTYPES
Value: 11 (int)

Total number of type tags.

luaLUA_OK
Value: 0 (int)

Status code for no errors.

luaLUA_OPADD
Value: 0 (int)

Code for addition in lua_arith.

luaLUA_OPBAND
Value: 7 (int)

Code for bitwise AND in lua_arith.

luaLUA_OPBNOT
Value: 13 (int)

Code for bitwise NOT in lua_arith.

luaLUA_OPBOR
Value: 8 (int)

Code for bitwise OR in lua_arith.

luaLUA_OPBXOR
Value: 9 (int)

Code for bitwise XOR in lua_arith.

luaLUA_OPDIV
Value: 5 (int)

Code for float division in lua_arith.

luaLUA_OPEQ
Value: 0 (int)

Code for equality in lua_compare.

luaLUA_OPIDIV
Value: 6 (int)

Code for floor division in lua_arith.

luaLUA_OPLE
Value: 2 (int)

Code for less-or-equal in lua_compare.

luaLUA_OPLT
Value: 1 (int)

Code for less-than in lua_compare.

luaLUA_OPMOD
Value: 3 (int)

Code for modulo in lua_arith.

luaLUA_OPMUL
Value: 2 (int)

Code for multiplication in lua_arith.

luaLUA_OPPOW
Value: 4 (int)

Code for exponentiation in lua_arith.

luaLUA_OPSHL
Value: 10 (int)

Code for left shift in lua_arith.

luaLUA_OPSHR
Value: 11 (int)

Code for right shift in lua_arith.

luaLUA_OPSUB
Value: 1 (int)

Code for subtraction in lua_arith.

luaLUA_OPUNM
Value: 12 (int)

Code for unary minus in lua_arith.

deprecatedlua_pcall
#define lua_pcall(L,n,r,f) lua_pcallk(L,(n),(r),(f),0,NULL)

Deprecated. Calls a function in protected mode.

deprecatedlua_pcallk
int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k)

Deprecated. Use CPROTECT_BEGIN/CPROTECT_END macros instead.

lualua_pop
#define lua_pop(L,n) lua_settop(L, -(n)-1)

Pops n elements from the stack.

lualua_pushboolean
void lua_pushboolean (lua_State *L, int b)
lualua_pushcclosure
void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n)
lualua_pushcfunction
#define lua_pushcfunction(L,f) lua_pushcclosure(L,(f),0)

Pushes a C function onto the stack (macro for lua_pushcclosure with 0 upvalues).

luslua_pushenum
void lua_pushenum (lua_State *L, int npairs)
lualua_pushexternalstring
const char *lua_pushexternalstring (lua_State *L, const char *s, size_t len, lua_Alloc falloc, void *ud)
lualua_pushfstring
const char *lua_pushfstring (lua_State *L, const char *fmt, ...)
lualua_pushglobaltable
#define lua_pushglobaltable(L) ((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS))

Pushes the global environment table onto the stack.

lualua_pushinteger
void lua_pushinteger (lua_State *L, lua_Integer n)
lualua_pushlightuserdata
void lua_pushlightuserdata (lua_State *L, void *p)
lualua_pushliteral
#define lua_pushliteral(L,s) lua_pushstring(L, "" s)

Pushes a literal string onto the stack.

lualua_pushlstring
const char *lua_pushlstring (lua_State *L, const char *s, size_t len)
lualua_pushnil
void lua_pushnil (lua_State *L)
lualua_pushnumber
void lua_pushnumber (lua_State *L, lua_Number n)
lualua_pushstring
const char *lua_pushstring (lua_State *L, const char *s)
lualua_pushthread
int lua_pushthread (lua_State *L)
lualua_pushvalue
void lua_pushvalue (lua_State *L, int idx)
lualua_pushvfstring
const char *lua_pushvfstring (lua_State *L, const char *fmt, va_list argp)
lualua_rawequal
int lua_rawequal (lua_State *L, int idx1, int idx2)
lualua_rawget
int lua_rawget (lua_State *L, int idx)
lualua_rawgeti
int lua_rawgeti (lua_State *L, int idx, lua_Integer n)
lualua_rawgetp
int lua_rawgetp (lua_State *L, int idx, const void *p)
lualua_rawlen
lua_Unsigned lua_rawlen (lua_State *L, int idx)
lualua_rawset
void lua_rawset (lua_State *L, int idx)
lualua_rawseti
void lua_rawseti (lua_State *L, int idx, lua_Integer n)
lualua_rawsetp
void lua_rawsetp (lua_State *L, int idx, const void *p)
lualua_Reader
typedef const char *(*lua_Reader)(lua_State *L, void *ud, size_t *sz);

The reader function used by lua_load.

lualua_register
#define lua_register(L,n,f) (lua_pushcfunction(L,(f)), lua_setglobal(L,(n)))

Sets the C function f as the new value of global n.

luaLUA_REGISTRYINDEX

Pseudo-index for the registry table.

lualua_remove
#define lua_remove(L,idx) (lua_rotate(L,(idx),-1), lua_pop(L,1))

Removes the element at the given valid index, shifting down elements above.

lualua_replace
#define lua_replace(L,idx) (lua_copy(L,-1,(idx)), lua_pop(L,1))

Moves the top element into the given valid index without shifting.

lualua_resume
int lua_resume (lua_State *L, lua_State *from, int narg, int *nres)
luaLUA_RIDX_GLOBALS
Value: 2 (int)

Registry index for the global environment table.

luaLUA_RIDX_MAINTHREAD
Value: 3 (int)

Registry index for the main thread.

lualua_rotate
void lua_rotate (lua_State *L, int idx, int n)
lualua_setallocf
void lua_setallocf (lua_State *L, lua_Alloc f, void *ud)
lualua_setfield
void lua_setfield (lua_State *L, int idx, const char *k)
lualua_setglobal
void lua_setglobal (lua_State *L, const char *name)
lualua_sethook
void lua_sethook (lua_State *L, lua_Hook func, int mask, int count)
lualua_seti
void lua_seti (lua_State *L, int idx, lua_Integer n)
lualua_setiuservalue
int lua_setiuservalue (lua_State *L, int idx, int n)
lualua_setlocal
const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n)
lualua_setmetatable
int lua_setmetatable (lua_State *L, int objindex)
lualua_settable
void lua_settable (lua_State *L, int idx)
lualua_settop
void lua_settop (lua_State *L, int idx)
lualua_setupvalue
const char *lua_setupvalue (lua_State *L, int funcindex, int n)
lualua_setuservalue
#define lua_setuservalue(L,idx) lua_setiuservalue(L,idx,1)

Compatibility macro. Sets the first user value of a userdata.

lualua_setwarnf
void lua_setwarnf (lua_State *L, lua_WarnFunction f, void *ud)
lualua_State
typedef struct lua_State lua_State;

An opaque structure that points to a thread and indirectly to the whole state of a Lua interpreter.

lualua_status
int lua_status (lua_State *L)
lualua_stringtonumber
size_t lua_stringtonumber (lua_State *L, const char *s)
luaLUA_TBOOLEAN
Value: 1 (int)

Tag for boolean values.

lusLUA_TENUM
Value: 9 (int)

Tag for enum values.

luaLUA_TFUNCTION
Value: 6 (int)

Tag for function values.

luaLUA_TLIGHTUSERDATA
Value: 2 (int)

Tag for light userdata.

luaLUA_TNIL
Value: 0 (int)

Tag for nil values.

luaLUA_TNONE
Value: -1 (int)

Tag for no value.

luaLUA_TNUMBER
Value: 3 (int)

Tag for number values.

lualua_toboolean
int lua_toboolean (lua_State *L, int idx)
lualua_tocfunction
lua_CFunction lua_tocfunction (lua_State *L, int idx)
lualua_toclose
void lua_toclose (lua_State *L, int idx)
lualua_tointeger
#define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL)

Converts the value at the given index to a lua_Integer.

lualua_tointegerx
lua_Integer lua_tointegerx (lua_State *L, int idx, int *isnum)
lualua_tolstring
const char *lua_tolstring (lua_State *L, int idx, size_t *len)
lualua_tonumber
#define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL)

Converts the value at the given index to a lua_Number.

lualua_tonumberx
lua_Number lua_tonumberx (lua_State *L, int idx, int *isnum)
lualua_topointer
const void *lua_topointer (lua_State *L, int idx)
lualua_tostring
#define lua_tostring(L,i) lua_tolstring(L,(i),NULL)

Equivalent to lua_tolstring with len equal to NULL.

lualua_tothread
lua_State *lua_tothread (lua_State *L, int idx)
lualua_touserdata
void *lua_touserdata (lua_State *L, int idx)
luaLUA_TSTRING
Value: 4 (int)

Tag for string values.

luaLUA_TTABLE
Value: 5 (int)

Tag for table values.

luaLUA_TTHREAD
Value: 8 (int)

Tag for thread (coroutine) values.

luaLUA_TUSERDATA
Value: 7 (int)

Tag for full userdata.

lusLUA_TVECTOR
Value: 10 (int)

Tag for vector values.

lualua_type
int lua_type (lua_State *L, int idx)
lualua_typename
const char *lua_typename (lua_State *L, int tp)
lualua_Unsigned
typedef unsigned long long lua_Unsigned;

The unsigned version of lua_Integer.

lualua_upvalueid
void *lua_upvalueid (lua_State *L, int fidx, int n)
lualua_upvalueindex
#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i))

Returns the pseudo-index for the i-th upvalue of a C closure.

lualua_upvaluejoin
void lua_upvaluejoin (lua_State *L, int fidx1, int n1, int fidx2, int n2)
lualua_version
lua_Number lua_version (lua_State *L)
lualua_WarnFunction
typedef void (*lua_WarnFunction)(void *ud, const char *msg, int tocont);

The type of warning functions.

lualua_warning
void lua_warning (lua_State *L, const char *msg, int tocont)
lualua_Writer
typedef int (*lua_Writer)(lua_State *L, const void *p, size_t sz, void *ud);

The writer function used by lua_dump.

lualua_xmove
void lua_xmove (lua_State *from, lua_State *to, int n)
lualua_yield
#define lua_yield(L,n) lua_yieldk(L,(n),0,NULL)

Yields a coroutine (macro for lua_yieldk with no continuation).

lualua_yieldk
int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k)

Auxiliary C API

luaLUA_ERRFILE
Value: 6 (int)

Error code for file-related errors in luaL_loadfile.

luaLUA_FILEHANDLE

Metatable name for file handles.

luaLUA_NOREF
Value: -2 (int)

Special reference value representing no reference.

luaLUA_REFNIL
Value: -1 (int)

Special reference value representing a reference to nil.

lualuaL_addchar
#define luaL_addchar(B,c)

Adds the byte c to the buffer B.

lualuaL_addgsub
void luaL_addgsub (luaL_Buffer *b, const char *s, const char *p, const char *r)
lualuaL_addlstring
void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l)
lualuaL_addsize
#define luaL_addsize(B,s) ((B)->n += (s))

Adds to the buffer a string of length s previously copied to the buffer area.

lualuaL_addstring
void luaL_addstring (luaL_Buffer *B, const char *s)
lualuaL_addvalue
void luaL_addvalue (luaL_Buffer *B)
lualuaL_alloc
void *luaL_alloc (void *ud, void *ptr, size_t osize, size_t nsize)
lualuaL_argcheck
#define luaL_argcheck(L,cond,arg,extramsg)

Checks whether cond is true. If not, raises an argument error.

lualuaL_argerror
int luaL_argerror (lua_State *L, int arg, const char *extramsg)
lualuaL_argexpected
#define luaL_argexpected(L,cond,arg,tname)

Checks whether cond is true. If not, raises a type error.

lualuaL_buffaddr
#define luaL_buffaddr(bf) ((bf)->b)

Returns the address of the buffer content.

lualuaL_Buffer
struct luaL_Buffer { char *b; size_t size; size_t n; lua_State *L; };

Type for a string buffer. A string buffer allows C code to build Lua strings piecemeal.

luaLUAL_BUFFERSIZE

The initial buffer size used by the buffer system.

lualuaL_buffinit
void luaL_buffinit (lua_State *L, luaL_Buffer *B)
lualuaL_buffinitsize
char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz)
lualuaL_bufflen
#define luaL_bufflen(bf) ((bf)->n)

Returns the current length of the buffer content.

lualuaL_buffsub
#define luaL_buffsub(B,s) ((B)->n -= (s))

Removes s bytes from the buffer.

lualuaL_callmeta
int luaL_callmeta (lua_State *L, int obj, const char *e)
lualuaL_checkany
void luaL_checkany (lua_State *L, int arg)
lualuaL_checkinteger
lua_Integer luaL_checkinteger (lua_State *L, int arg)
lualuaL_checklstring
const char *luaL_checklstring (lua_State *L, int arg, size_t *l)
lualuaL_checknumber
lua_Number luaL_checknumber (lua_State *L, int arg)
lualuaL_checkoption
int luaL_checkoption (lua_State *L, int arg, const char *def, const char *const lst[])
lualuaL_checkstack
void luaL_checkstack (lua_State *L, int sz, const char *msg)
lualuaL_checkstring
#define luaL_checkstring(L,n) (luaL_checklstring(L,(n),NULL))

Checks whether the function argument n is a string and returns it.

lualuaL_checktype
void luaL_checktype (lua_State *L, int arg, int t)
lualuaL_checkudata
void *luaL_checkudata (lua_State *L, int ud, const char *tname)
lualuaL_checkversion
#define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES)

Checks that the code making the call and the Lua library being called are using the same version of Lua and compatible numeric types.

lualuaL_checkversion_
void luaL_checkversion_ (lua_State *L, lua_Number ver, size_t sz)
lualuaL_dofile
#define luaL_dofile(L,fn) (luaL_loadfile(L,fn) || lua_pcall(L,0,LUA_MULTRET,0))

Loads and runs the given file.

lualuaL_dostring
#define luaL_dostring(L,s) (luaL_loadstring(L,s) || lua_pcall(L,0,LUA_MULTRET,0))

Loads and runs the given string.

lualuaL_error
int luaL_error (lua_State *L, const char *fmt, ...)
lualuaL_execresult
int luaL_execresult (lua_State *L, int stat)
lualuaL_fileresult
int luaL_fileresult (lua_State *L, int stat, const char *fname)
lualuaL_getmetafield
int luaL_getmetafield (lua_State *L, int obj, const char *e)
lualuaL_getmetatable
#define luaL_getmetatable(L,n) (lua_getfield(L,LUA_REGISTRYINDEX,(n)))

Pushes onto the stack the metatable associated with the name n in the registry.

lualuaL_getsubtable
int luaL_getsubtable (lua_State *L, int idx, const char *fname)
lualuaL_gsub
const char *luaL_gsub (lua_State *L, const char *s, const char *p, const char *r)
lualuaL_len
lua_Integer luaL_len (lua_State *L, int idx)
lualuaL_loadbuffer
#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL)

Loads a buffer as a Lua chunk.

lualuaL_loadbufferx
int luaL_loadbufferx (lua_State *L, const char *buff, size_t sz, const char *name, const char *mode)
lualuaL_loadfile
#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL)

Loads a file as a Lua chunk (macro for luaL_loadfilex with NULL mode).

lualuaL_loadfilex
int luaL_loadfilex (lua_State *L, const char *filename, const char *mode)
lualuaL_loadstring
int luaL_loadstring (lua_State *L, const char *s)
lualuaL_makeseed
unsigned luaL_makeseed (lua_State *L)
lualuaL_newlib
#define luaL_newlib(L,l) (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))

Creates a new table and registers the functions in l into it.

lualuaL_newlibtable
#define luaL_newlibtable(L,l) lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)

Creates a table with a size hint for the number of entries in l.

lualuaL_newmetatable
int luaL_newmetatable (lua_State *L, const char *tname)
lualuaL_newstate
lua_State *luaL_newstate (void)
luaLUAL_NUMSIZES

Encodes the size of integers and floats for version checking.

lualuaL_optinteger
lua_Integer luaL_optinteger (lua_State *L, int arg, lua_Integer def)
lualuaL_optlstring
const char *luaL_optlstring (lua_State *L, int arg, const char *def, size_t *l)
lualuaL_optnumber
lua_Number luaL_optnumber (lua_State *L, int arg, lua_Number def)
lualuaL_optstring
#define luaL_optstring(L,n,d) (luaL_optlstring(L,(n),(d),NULL))

If the function argument n is a string, returns it; otherwise returns d.

lualuaL_prepbuffer
#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE)

Equivalent to luaL_prepbuffsize with LUAL_BUFFERSIZE.

lualuaL_prepbuffsize
char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz)
lualuaL_pushfail
#define luaL_pushfail(L) lua_pushnil(L)

Pushes the fail value onto the stack.

lualuaL_pushresult
void luaL_pushresult (luaL_Buffer *B)
lualuaL_pushresultsize
void luaL_pushresultsize (luaL_Buffer *B, size_t sz)
lualuaL_ref
int luaL_ref (lua_State *L, int t)
lualuaL_Reg
typedef struct luaL_Reg { const char *name; lua_CFunction func; } luaL_Reg;

Type for arrays of functions to be registered with luaL_setfuncs.

lualuaL_requiref
void luaL_requiref (lua_State *L, const char *modname, lua_CFunction openf, int glb)
lualuaL_setfuncs
void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup)
lualuaL_setmetatable
void luaL_setmetatable (lua_State *L, const char *tname)
lualuaL_Stream
typedef struct luaL_Stream { FILE *f; lua_CFunction closef; } luaL_Stream;

The internal structure used by the standard I/O library for file handles.

lualuaL_testudata
void *luaL_testudata (lua_State *L, int ud, const char *tname)
lualuaL_tolstring
const char *luaL_tolstring (lua_State *L, int idx, size_t *len)
lualuaL_traceback
void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, int level)
lualuaL_typeerror
int luaL_typeerror (lua_State *L, int arg, const char *tname)
lualuaL_typename
#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))

Returns the name of the type of the value at the given index.

lualuaL_unref
void luaL_unref (lua_State *L, int t, int ref)
lualuaL_where
void luaL_where (lua_State *L, int lvl)

Other

unstablevector.archive.brotli.compress(data: string|vector, [quality: integer], [lgwin: integer])

Compresses data using Brotli format (RFC 7932). The optional quality (0-11, default 11) controls compression quality. The optional lgwin (10-24, default 22) sets the LZ77 window size. Returns the same type as the input.

unstablevector.archive.brotli.decompress(data: string|vector)

Decompresses Brotli-compressed data. Returns the same type as the input.

unstablevector.archive.deflate.compress(data: string|vector, [level: integer])

Compresses data using raw deflate format (RFC 1951) without headers. The optional level (0-9, default 6) controls the compression ratio. Returns the same type as the input.

unstablevector.archive.deflate.decompress(data: string|vector)

Decompresses raw deflate-compressed data. No header or checksum validation is performed. Returns the same type as the input.

unstablevector.archive.gzip.compress(data: string|vector, [level: integer])

Compresses data using gzip format. The optional level (0-9, default 6) controls the compression ratio. Returns the same type as the input.

unstablevector.archive.gzip.decompress(data: string|vector)

Decompresses gzip-compressed data. Validates the gzip header and CRC32 checksum. Returns the same type as the input.

unstablevector.archive.lz4.compress(data: string|vector, [level: integer])

Compresses data using LZ4 frame format. The optional level (1-12, default 1) controls the speed-ratio trade-off. Returns the same type as the input.

unstablevector.archive.lz4.decompress(data: string|vector)

Decompresses LZ4 frame-compressed data. Validates the frame header and optional checksum. Returns the same type as the input.

unstablevector.archive.lz4.decompress_hc(data: string|vector)

Decompresses LZ4 HC (legacy high-compression) format data. Provided for backward compatibility with older LZ4 HC implementations. Prefer decompress for new code. Returns the same type as the input.

unstablevector.archive.zstd.compress(data: string|vector, [level: integer])

Compresses data using Zstandard format (RFC 8878). The optional level (-7 to 22, default 3) controls the speed-ratio trade-off. Returns the same type as the input.

unstablevector.archive.zstd.decompress(data: string|vector)

Decompresses Zstandard-compressed data. Validates the frame header and optional content checksum. Returns the same type as the input.