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

luaL_where[-0, +1, m] void luaL_where (lua_State *L, int lvl); Pushes onto the stack a string

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

luaL_Stream typedef struct luaL_Stream { FILE *f; lua_CFunction closef; } luaL_Stream; The standard representation for file handles

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

luaL_openlibs[-0, +0, e] void luaL_openlibs (lua_State *L); Opens all standard Lua libraries into

2025-01-10 15:47:30