### Lua Argument Table Example Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Illustrates the structure of the global 'arg' table, which holds command-line arguments passed to a Lua script. ```lua arg = { [-2] = "lua", [-1] = "-la", [0] = "b.lua", [1] = "t1", [2] = "t2" } ``` -------------------------------- ### Lua Execution with -e and arg[1] Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Example showing how arguments are accessed within Lua when using the -e option without a script file. ```bash $ lua -e "print(arg[1])" ``` -------------------------------- ### Lua Script Shebang Line Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Example of a shebang line for making a Lua script executable on Unix-like systems. ```bash #!/usr/local/bin/lua ``` ```bash #!/usr/bin/env lua ``` -------------------------------- ### lua_yieldk Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Yields the coroutine (thread). When a C function calls `lua_yieldk`, the current coroutine is suspended, and the call to `lua_resume` that started this thread returns. ```APIDOC ## lua_yieldk ### Description Yields the coroutine (thread). When a C function calls `lua_yieldk`, the current coroutine is suspended, and the call to `lua_resume` that started this thread returns. The parameter `nresults` indicates the number of return values on the stack to be returned to `lua_resume`. When the coroutine is resumed, Lua calls the continuation function `k` to continue running the suspended C function (see §4.7). The continuation function receives the same stack as the previous function, with the `n` return values removed and the arguments passed from `lua_resume` pushed onto the stack. Additionally, the continuation function receives the `ctx` argument passed to `lua_yieldk`. Normally, this function does not return; when the coroutine is resumed, it continues running from the continuation function. However, there is an exception: when this function is called from a step hook (see §4.9), `lua_yieldk` cannot provide a continuation function (i.e., it is called like `lua_yield`), and the hook function will return immediately after the yield. Lua will yield the coroutine, and once the coroutine is resumed, the function that triggered the hook will continue running normally. Calling this function when a C call is not in continuation mode (e.g., the main thread) throws an error. It also throws an error when called from a thread that was not started in continuation mode (e.g., the main thread). ### Signature int lua_yieldk ( lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k ); ``` -------------------------------- ### Lua Execution with Multiple -e Options Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Demonstrates executing multiple string statements sequentially using the -e option before running a script. ```bash $ lua -e'a=1' -e 'print(a)' script.lua ``` -------------------------------- ### luaL_buffinit Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Initializes a buffer `B`. This function does not allocate any space. ```APIDOC ## luaL_buffinit ### Description Initializes a buffer `B`. This function does not allocate any space; the buffer must be declared as a variable. ### Signature ```c void luaL_buffinit (lua_State *L, luaL_Buffer *B); ``` ``` -------------------------------- ### Lua Command-Line Usage Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md The basic command-line syntax for the standalone Lua interpreter. Options can control execution, module loading, and interactive mode. ```bash lua [options] [script [args]] ``` -------------------------------- ### luaL_buffinitsize Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Equivalent to calling `luaL_buffinit` followed by `luaL_prepbuffsize`. ```APIDOC ## luaL_buffinitsize ### Description Equivalent to calling `luaL_buffinit` followed by `luaL_prepbuffsize`. ### Signature ```c char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz); ``` ``` -------------------------------- ### Lua Environment Variable Initialization Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md How Lua checks environment variables like LUA_INIT for initialization scripts or strings before executing arguments. ```bash LUA_INIT_5_3 ``` ```bash LUA_INIT ``` -------------------------------- ### Lua Interpreter Options Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Common options for the Lua interpreter, including executing strings, loading modules, entering interactive mode, and version display. ```bash -e _stat_ ``` ```bash -l _mod_ ``` ```bash -i ``` ```bash -v ``` ```bash -E ``` ```bash -- ``` ```bash "-" ``` -------------------------------- ### Package Module Functions and Variables Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Reference for the 'package' module, which provides functions for loading modules and managing package paths. ```APIDOC ## require (modname) ### Description Loads a module. It checks `package.loaded` first, then searches for a loader using `package.searchers` (which includes `package.preload`, Lua path, C path, and the 'all-in-one' loader). ### Parameters * **modname** (string) - The name of the module to load. ### Returns The loaded module's value. ### Errors Throws an error if the module cannot be loaded or run, or if no loader is found. ``` ```APIDOC ## package.config ### Description A string describing compile-time configuration information for the package management system. It contains directory separators, path separators, template replacement strings, and more. ### Type string ``` ```APIDOC ## package.cpath ### Description The path used by `require` when searching for C loaders. It is initialized from the `LUA_CPATH_5_3` or `LUA_CPATH` environment variables, or from default paths defined in `luaconf.h`. ### Type string ``` ```APIDOC ## package.loaded ### Description A table used by `require` to control which modules have already been loaded. If `package.loaded[modname]` is not false, `require` returns the stored value. ### Type table ``` ```APIDOC ## package.loadlib (libname, funcname) ### Description Dynamically links a C library `libname`. If `funcname` is "*", it just links the library. Otherwise, it searches for the function `funcname` within the library and returns it as a C function. ### Parameters * **libname** (string) - The name of the C library to load. * **funcname** (string) - The name of the function to find within the library. ### Returns A C function if `funcname` is specified, otherwise the result of the linking operation. ### Notes This is a low-level function that bypasses the package module system. It is not supported on all platforms. ``` ```APIDOC ## package.path ### Description The path used by `require` when searching for Lua loaders. It is initialized from the `LUA_PATH_5_3` or `LUA_PATH` environment variables, or from default paths defined in `luaconf.h`. ### Type string ``` ```APIDOC ## package.preload ### Description A table holding loaders for special modules. `require` checks this table before searching other paths. ### Type table ``` ```APIDOC ## package.searchers ### Description A table of _searcher functions_ used by `require` to control how modules are loaded. `require` calls these searchers in order. ### Type table ``` ```APIDOC ## package.searchpath (name, path [, sep [, rep]]) ### Description Searches for `name` in the given `path`. The path is a string of semicolon-separated templates. It replaces placeholders in the templates with `name` and `sep`/`rep` values, then attempts to open the resulting filename. ### Parameters * **name** (string) - The name to search for. * **path** (string) - The path string containing templates. * **sep** (string, optional) - The separator character to replace (defaults to '.'). * **rep** (string, optional) - The replacement for the separator (defaults to the system's directory separator). ### Returns The name of the first file that can be opened for reading, or nil plus an error message if no such file is found. ``` -------------------------------- ### lua_getstack Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Retrieves information about the Lua interpreter's runtime stack. ```APIDOC ## lua_getstack ```c int lua_getstack (lua_State *L, int level, lua_Debug *ar); ``` ### Description Fills a `lua_Debug` structure with information about the function at the given level in the Lua stack. Level 0 is the currently running function. ### Method `lua_getstack` ### Parameters * **L** (`lua_State*`) - The Lua state. * **level** (`int`) - The stack level to query (0 is the current function). * **ar** (`lua_Debug*`) - A pointer to a `lua_Debug` structure to be filled. ### Returns * `int` - Returns 1 if the stack level is valid, 0 otherwise. ``` -------------------------------- ### luaL_checkstack Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Expands the stack space to `top + sz` elements. Throws an error if expansion is not possible. ```APIDOC ## luaL_checkstack ### Description Expands the stack space to `top + sz` elements. Throws an error if expansion is not possible. `msg` is additional text for the error message (`NULL` means no extra text). ### Signature ```c void luaL_checkstack (lua_State *L, int sz, const char *msg); ``` ``` -------------------------------- ### lua_getinfo Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Retrieves information about a function or function call. ```APIDOC ## lua_getinfo ```c int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); ``` ### Description Retrieves information about a specified function or function call. The `what` string specifies which fields of the `lua_Debug` structure to fill or what to push onto the stack. ### Method `lua_getinfo` ### Parameters * **L** (`lua_State*`) - The Lua state. * **what** (`const char*`) - A string specifying which information to retrieve. Possible characters include: * `'n'`: fills `name` and `namewhat`. * `'S'`: fills `source`, `short_src`, `linedefined`, `lastlinedefined`, and `what`. * `'l'`: fills `currentline`. * `'t'`: fills `istailcall`. * `'u'`: fills `nups`, `nparams`, and `isvararg`. * `'f'`: pushes the function itself onto the stack. * `'L'`: pushes a table describing valid line numbers for breakpoints. * **ar** (`lua_Debug*`) - A pointer to a `lua_Debug` structure to be filled. If `what` starts with '`>`', the function is popped from the stack and `ar` is not used. ### Returns * `int` - Returns 0 on error (e.g., invalid option in `what`), otherwise returns a non-zero value. ``` -------------------------------- ### String Module Functions Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Reference for the 'string' module, providing general string manipulation functions like finding, sub-strings, and pattern matching. ```APIDOC ## string.byte (s [, i [, j]]) ### Description Returns the numerical internal codes of the characters in `s` between indices `i` and `j` (inclusive). Indices are 1-based and can be negative. ### Parameters * **s** (string) - The input string. * **i** (integer, optional) - The starting index (defaults to 1). * **j** (integer, optional) - The ending index (defaults to `i`). ### Returns A sequence of numerical codes for the characters. ### Notes Numerical codes are not guaranteed to be portable across platforms. The string library assumes a single-byte character encoding. ``` -------------------------------- ### luaL_addstring Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Adds a zero-terminated string `s` to the buffer `B`. ```APIDOC ## luaL_addstring ### Description Adds a zero-terminated string `s` to the buffer `B`. ### Signature ```c void luaL_addstring (luaL_Buffer *B, const char *s); ``` ``` -------------------------------- ### luaL_addlstring Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Adds a string `s` of length `l` to the buffer `B`. The string can contain null characters. ```APIDOC ## luaL_addlstring ### Description Adds a string `s` of length `l` to the buffer `B`. The string can contain null characters. ### Signature ```c void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l); ``` ``` -------------------------------- ### Add Pre-copied Data to Buffer Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Informs the luaL_Buffer that 'n' bytes have been copied into the pre-allocated space. This is used in conjunction with luaL_prepbuffer. ```c void luaL_addsize (luaL_Buffer *B, size_t n); ``` -------------------------------- ### luaL_addchar Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Adds a single byte `c` to the buffer `B`. ```APIDOC ## luaL_addchar ### Description Adds a single byte `c` to the buffer `B`. ### Signature ```c void luaL_addchar (luaL_Buffer *B, char c); ``` ``` -------------------------------- ### Check Option from List Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Checks if the argument at the specified index is a string and finds its index in a provided list of options. Handles default values and raises errors for mismatches. ```c int luaL_checkoption (lua_State *L, int arg, const char *def, const char *const lst[]); ``` -------------------------------- ### luaL_addsize Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Adds a string of length `n` to the buffer `B`, which was previously copied into the buffer. ```APIDOC ## luaL_addsize ### Description Adds a string of length `n` to the buffer `B`, which was previously copied into the buffer. ### Signature ```c void luaL_addsize (luaL_Buffer *B, size_t n); ``` ``` -------------------------------- ### luaL_addvalue Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Adds the value at the top of the stack to the buffer `B` and then pops it. ```APIDOC ## luaL_addvalue ### Description Adds the value at the top of the stack to the buffer `B` and then pops it. This function is the only one in the string buffer manipulation functions that will (and must) place an extra element on the stack. This element will be added to the buffer. ### Signature ```c void luaL_addvalue (luaL_Buffer *B); ``` ``` -------------------------------- ### lua_getlocal Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Retrieves information about a local variable in a given stack frame. ```APIDOC ## lua_getlocal ```c const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); ``` ### Description Gets information about a local variable from a given active record or from a function. Pushes the variable's value onto the stack and returns its name. ### Method `lua_getlocal` ### Parameters * **L** (`lua_State*`) - The Lua state. * **ar** (`const lua_Debug*`) - An active record obtained from `lua_getstack` or a hook. If `NULL`, the function to inspect must be at the top of the stack. * **n** (`int`) - The index of the local variable to retrieve. ### Returns * `const char*` - The name of the variable, or `NULL` if the index is out of bounds. The value of the variable is pushed onto the stack. ``` -------------------------------- ### luaL_checkoption Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Checks if the `arg`-th argument is a string and searches for it in the array `lst`. Returns the index of the matched string in the array. Throws an error if the argument is not a string or if no match is found. ```APIDOC ## luaL_checkoption ### Description Checks if the `arg`-th argument is a string and searches for it in the array `lst`. Returns the index of the matched string in the array. Throws an error if the argument is not a string or if no match is found. If `def` is not NULL, it is used as a default value when the argument `arg` is absent or nil. This function is typically used to map strings to C enumerated types. ### Signature ```c int luaL_checkoption (lua_State *L, int arg, const char *def, const char *const lst[]); ``` ``` -------------------------------- ### Lua Interactive Mode Prompt Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md The behavior of the Lua interpreter in interactive mode, displaying prompts and evaluating input as expressions or statements. ```lua -- In interactive mode, Lua displays prompts and waits for input. ``` -------------------------------- ### lua_gethook Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Retrieves the current hook function set for the Lua state. ```APIDOC ## lua_gethook ```c lua_Hook lua_gethook (lua_State *L); ``` ### Description Returns the current hook function. ### Method `lua_gethook` ### Parameters * **L** (`lua_State*`) - The Lua state. ### Returns * `lua_Hook` - The current hook function. ``` -------------------------------- ### Check Condition for Argument Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Verifies if a condition is true for a function argument. If false, it raises an error with a standard message format. ```c void luaL_argcheck (lua_State *L, int cond, int arg, const char *extramsg); ``` -------------------------------- ### luaL_checklstring Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Checks if the `arg`-th argument is a string and returns it. If `l` is not NULL, it fills `*l` with the string's length. This function uses `lua_tolstring` for retrieval. ```APIDOC ## luaL_checklstring ### Description Checks if the `arg`-th argument is a string and returns it. If `l` is not NULL, it fills `*l` with the string's length. This function uses `lua_tolstring` for retrieval, so any conversions that `lua_tolstring` can perform are also valid here. ### Signature ```c const char *luaL_checklstring (lua_State *L, int arg, size_t *l); ``` ``` -------------------------------- ### luaL_Buffer Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Type for string buffers, allowing C code to construct Lua strings incrementally. ```APIDOC ## luaL_Buffer ### Description Type for string buffers, allowing C code to construct Lua strings incrementally. The usage pattern involves initializing a `luaL_Buffer` variable, adding string fragments using `luaL_add*` functions, and finally calling `luaL_pushresult` to get the resulting string on the stack. Pre-allocation is possible with `luaL_buffinitsize` and `luaL_pushresultsize`. ### Type Definition ```c typedef struct luaL_Buffer luaL_Buffer; ``` ``` -------------------------------- ### Add Null-Terminated String to Buffer Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Appends a null-terminated string to a luaL_Buffer. This is a common way to add string data when building Lua strings in C. ```c void luaL_addstring (luaL_Buffer *B, const char *s); ``` -------------------------------- ### luaL_argerror Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Throws an error reporting a problem with the `arg`-th argument of the called C function. ```APIDOC ## luaL_argerror ### Description Throws an error reporting a problem with the `arg`-th argument of the called C function. It uses the following standard message and includes `extramsg` as an annotation: `bad argument #_arg_ to '_funcname_' (_extramsg_) This function never returns. ### Signature ```c int luaL_argerror (lua_State *L, int arg, const char *extramsg); ``` ``` -------------------------------- ### Add String Segment to Buffer Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Appends a string segment of a specified length, including null characters, to a luaL_Buffer. Useful for building Lua strings in C. ```c void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l); ``` -------------------------------- ### luaL_argcheck Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Checks if `cond` is true. If not, it throws an error with a standard message. ```APIDOC ## luaL_argcheck ### Description Checks if `cond` is true. If not, it throws an error with a standard message. ### Signature ```c void luaL_argcheck (lua_State *L, int cond, int arg, const char *extramsg); ``` ``` -------------------------------- ### luaL_checkstring Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Checks if the `arg`-th argument is a string and returns it. This function uses `lua_tolstring` for retrieval. ```APIDOC ## luaL_checkstring ### Description Checks if the `arg`-th argument is a string and returns it. This function uses `lua_tolstring` for retrieval, so any conversions that `lua_tolstring` can perform are also valid here. ### Signature ```c const char *luaL_checkstring (lua_State *L, int arg); ``` ``` -------------------------------- ### luaL_callmeta Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Calls a metamethod. Returns true if the object at index `obj` has a metatable with the field `e`, and the corresponding metamethod is called. ```APIDOC ## luaL_callmeta ### Description Calls a metamethod. Returns true if the object at index `obj` has a metatable with the field `e`, and the corresponding metamethod is called. The function returns true and pushes the call's return values onto the stack. If there is no metatable or no corresponding metamethod, it returns false (and pushes nothing onto the stack). ### Signature ```c int luaL_callmeta (lua_State *L, int obj, const char *e); ``` ``` -------------------------------- ### lua_Debug Structure Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md The `lua_Debug` structure holds information about a Lua function or an active stack frame. It is populated by functions like `lua_getinfo` and `lua_getstack`. ```APIDOC ## lua_Debug Structure ```c typedef struct lua_Debug { int event; const char *name; const char *namewhat; const char *what; const char *source; int currentline; int linedefined; int lastlinedefined; unsigned char nups; unsigned char nparams; char isvararg; char istailcall; char short_src[LUA_IDSIZE]; /* Private part */ _other fields_ } lua_Debug; ``` ### Fields: * **`source`**: Name of the code block where the function was created. Prefixed with '@' for files, '=' for user-defined sources. * **`short_src`**: A printable version of `source` for error messages. * **`linedefined`**: Line number where the function definition starts. * **`lastlinedefined`**: Line number where the function definition ends. * **`what`**: Type of the function ('Lua', 'C', 'main'). * **`currentline`**: The line number currently being executed. -1 if not available. * **`name`**: A reasonable name for the function. NULL if not found. * **`namewhat`**: Explanation of the `name` field ('global', 'local', 'method', 'field', 'upvalue', ''). * **`istailcall`**: True if the function was called in a tail call. * **`nups`**: Number of upvalues. * **`nparams`**: Number of fixed parameters (0 for C functions). * **`isvararg`**: True if the function is a variadic function (true for C functions). ``` -------------------------------- ### luaL_checkinteger Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Checks if the `arg`-th argument is an integer (or can be converted to one) and returns it as a `lua_Integer`. ```APIDOC ## luaL_checkinteger ### Description Checks if the `arg`-th argument is an integer (or can be converted to one) and returns it as a `lua_Integer`. ### Signature ```c lua_Integer luaL_checkinteger (lua_State *L, int arg); ``` ``` -------------------------------- ### lua_yield Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Yields the coroutine (thread). Equivalent to calling `lua_yieldk` without providing a continuation function. ```APIDOC ## lua_yield ### Description This function is equivalent to calling [`lua_yieldk`](#lua_yieldk), but without providing a continuation function (see §4.7). Therefore, when the thread is resumed, it will continue running the function that called `lua_yield`. ### Signature int lua_yield (lua_State *L, int nresults); ``` -------------------------------- ### luaL_checkany Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Checks if the function has any argument (including nil) at position `arg`. ```APIDOC ## luaL_checkany ### Description Checks if the function has any argument (including nil) at position `arg`. ### Signature ```c void luaL_checkany (lua_State *L, int arg); ``` ``` -------------------------------- ### lua_getupvalue Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Retrieves information about an upvalue of a closure. ```APIDOC ## lua_getupvalue ```c const char *lua_getupvalue (lua_State *L, int funcindex, int n); ``` ### Description Gets the `n`-th upvalue of a closure. Pushes the upvalue's value onto the stack and returns its name. `funcindex` indicates the stack index where the closure is located. ### Method `lua_getupvalue` ### Parameters * **L** (`lua_State*`) - The Lua state. * **funcindex** (`int`) - The stack index of the closure. * **n** (`int`) - The index of the upvalue to retrieve. ### Returns * `const char*` - The name of the upvalue, or `NULL` if the index is out of bounds. The value of the upvalue is pushed onto the stack. For C functions, upvalue names are always empty strings. ``` -------------------------------- ### luaL_checknumber Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Checks if the `arg`-th argument is a number and returns it. ```APIDOC ## luaL_checknumber ### Description Checks if the `arg`-th argument is a number and returns it. ### Signature ```c lua_Number luaL_checknumber (lua_State *L, int arg); ``` ``` -------------------------------- ### lua_gethookcount Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Retrieves the current hook count set for the Lua state. ```APIDOC ## lua_gethookcount ```c int lua_gethookcount (lua_State *L); ``` ### Description Returns the current hook count. ### Method `lua_gethookcount` ### Parameters * **L** (`lua_State*`) - The Lua state. ### Returns * `int` - The current hook count. ``` -------------------------------- ### Add Character to Buffer Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Appends a single byte to a luaL_Buffer. This is part of a sequence for building Lua strings in C. ```c void luaL_addchar (luaL_Buffer *B, char c); ``` -------------------------------- ### lua_gethookmask Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Retrieves the current hook mask set for the Lua state. ```APIDOC ## lua_gethookmask ```c int lua_gethookmask (lua_State *L); ``` ### Description Returns the current hook mask. ### Method `lua_gethookmask` ### Parameters * **L** (`lua_State*`) - The Lua state. ### Returns * `int` - The current hook mask. ``` -------------------------------- ### Add Stack Value to Buffer Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Appends the value at the top of the Lua stack to the buffer and pops it. This is the only buffer function that manipulates the stack. ```c void luaL_addvalue (luaL_Buffer *B); ``` -------------------------------- ### Report Argument Error Source: https://github.com/openluat/luatos-wiki/blob/master/luaGuide/luaReference.md Raises an error indicating a problem with a specific argument to a C function. It formats a standard error message including extra context. ```c int luaL_argerror (lua_State *L, int arg, const char *extramsg); ```