4.8 – Functions and Types[-o, +p, x]

Here we list all functions and types from the C API in alphabetical order. Each function has an indicator like this:

The first field, o, is how many elements the function pops from the stack. The second field, p, is how many elements the function pushes onto the stack. (Any function always pushes its results after popping its arguments.) A field in the form x|y means the function can push (or pop) x or y elements, depending on the situation; an interrogation mark '?' means that we cannot know how many elements the function pops/pushes by looking only at its arguments (e.g., they may depend on what is on the stack). The third field, x, tells whether the function may raise errors: '-' means the function never raises any error; 'm' means the function may raise out-of-memory errors and errors running a __gc metamethod; 'e' means the function may raise any errors (it can run arbitrary Lua code, either directly or through metamethods); 'v' means the function may raise an error on purpose.

lua_settop
  • References/Lua/Lua/API/Functions and Types

lua_settop[-?, +?, –] void lua_settop (lua_State *L, int index); Accepts any index, or 0, and sets the

2025-01-10 15:47:30
lua_settable
  • References/Lua/Lua/API/Functions and Types

lua_settable[-2, +0, e] void lua_settable (lua_State *L, int index); Does the equivalent to t[k]

2025-01-10 15:47:30
lua_newthread
  • References/Lua/Lua/API/Functions and Types

lua_newthread[-0, +1, m] lua_State *lua_newthread (lua_State *L); Creates a new thread, pushes

2025-01-10 15:47:30
lua_newstate
  • References/Lua/Lua/API/Functions and Types

lua_newstate[-0, +0, –] lua_State *lua_newstate (lua_Alloc f, void *ud); Creates a new thread running in

2025-01-10 15:47:30
lua_upvalueindex
  • References/Lua/Lua/API/Functions and Types

lua_upvalueindex[-0, +0, –] int lua_upvalueindex (int i); Returns the pseudo-index that represents the

2025-01-10 15:47:30
lua_pushnumber
  • References/Lua/Lua/API/Functions and Types

lua_pushnumber[-0, +1, –] void lua_pushnumber (lua_State *L, lua_Number n); Pushes a float with value n

2025-01-10 15:47:30
lua_pushliteral
  • References/Lua/Lua/API/Functions and Types

lua_pushliteral[-0, +1, m] const char *lua_pushliteral (lua_State *L, const char *s); This macro

2025-01-10 15:47:30
lua_setuservalue
  • References/Lua/Lua/API/Functions and Types

lua_setuservalue[-1, +0, –] void lua_setuservalue (lua_State *L, int index); Pops a value from the stack

2025-01-10 15:47:30
lua_setmetatable
  • References/Lua/Lua/API/Functions and Types

lua_setmetatable[-1, +0, –] void lua_setmetatable (lua_State *L, int index); Pops a table from the stack

2025-01-10 15:47:30
lua_KFunction
  • References/Lua/Lua/API/Functions and Types

lua_KFunction typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx); Type for continuation functions (see

2025-01-10 15:47:30