5 – The Auxiliary Library

The auxiliary library provides several convenient functions to interface C with Lua. While the basic API provides the primitive functions for all interactions between C and Lua, the auxiliary library provides higher-level functions for some common tasks.

All functions and types from the auxiliary library are defined in header file lauxlib.h and have a prefix luaL_.

All functions in the auxiliary library are built on top of the basic API, and so they provide nothing that cannot be done with that API. Nevertheless, the use of the auxiliary library ensures more consistency to your code.

Several functions in the auxiliary library use internally some extra stack slots. When a function in the auxiliary library uses less than five slots, it does not check the stack size; it simply assumes that there are enough slots.

Several functions in the auxiliary library are used to check C function arguments. Because the error message is formatted for arguments (e.g., "bad argument #1"), you should not use these functions for other stack values.

Functions called luaL_check* always raise an error if the check is not satisfied.

luaL_gsub
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_gsub[-0, +1, m] const char *luaL_gsub (lua_State *L, const char *s,

2025-01-10 15:47:30
luaL_argerror
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_argerror[-0, +0, v] int luaL_argerror (lua_State *L, int arg, const char *extramsg); Raises

2025-01-10 15:47:30
luaL_checkinteger
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_checkinteger[-0, +0, v] lua_Integer luaL_checkinteger (lua_State *L, int arg); Checks whether

2025-01-10 15:47:30
luaL_loadbufferx
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_loadbufferx[-0, +1, –] int luaL_loadbufferx (lua_State *L, const char *buff,

2025-01-10 15:47:30
luaL_newmetatable
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_newmetatable[-0, +1, m] int luaL_newmetatable (lua_State *L, const char *tname); If the registry

2025-01-10 15:47:30
luaL_requiref
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_requiref[-0, +1, e] void luaL_requiref (lua_State *L, const char *modname, lua_CFunction

2025-01-10 15:47:30
luaL_buffinitsize
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_buffinitsize[-?, +?, m] char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz);

2025-01-10 15:47:30
luaL_checkstring
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_checkstring[-0, +0, v] const char *luaL_checkstring (lua_State *L, int arg); Checks whether

2025-01-10 15:47:30
luaL_Buffer
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_Buffer typedef struct luaL_Buffer luaL_Buffer; Type for a string buffer. A string buffer allows C code to build

2025-01-10 15:47:30
luaL_error
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_error[-0, +0, v] int luaL_error (lua_State *L, const char *fmt, ...); Raises an error. The

2025-01-10 15:47:30