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_dofile
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_dofile[-0, +?, e] int luaL_dofile (lua_State *L, const char *filename); Loads and runs the

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

luaL_checkoption[-0, +0, v] int luaL_checkoption (lua_State *L, int arg,

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

luaL_traceback[-0, +1, m] void luaL_traceback (lua_State *L, lua_State *L1, const char *msg,

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_pushresult
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_pushresult[-?, +1, m] void luaL_pushresult (luaL_Buffer *B); Finishes the use of buffer B

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_dostring
  • References/Lua/Lua/Auxiliary Library/Functions and Types

luaL_dostring[-0, +?, –] int luaL_dostring (lua_State *L, const char *str); Loads and runs the given string

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

luaL_loadfile[-0, +1, m] int luaL_loadfile (lua_State *L, const char *filename); Equivalent to

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

luaL_tolstring[-0, +1, e] const char *luaL_tolstring (lua_State *L, int idx, size_t *len); Converts

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

luaL_optlstring[-0, +0, v] const char *luaL_optlstring (lua_State *L, int arg

2025-01-10 15:47:30