Last edit: 07.02.2010 Lua 5.1 C API
© Ewald Arnold <lua_at_ewald-arnold.de> 1/7
R P1 P2 P3 P4 POP Stack IN PUSH Stack OUT
L 0 +1 -1: -
L n 0 +1 -1: -
L n 0 +1 -1: -
L 0 +1 -1: -
L 0 +1 -1: -
L 0 +1 -1: m
L … 0 +1 -1: m
L 0 +1 -1: m
L 0 +1 -1: m
L n -n -1: +1 -1: m
-n:
L 0 +1 -1: -
L 0 +1 -1: -
L 0 +1 -1: -
R P1 P2 P3 P4 POP Stack IN PUSH Stack OUT
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
R P1 P2 P3 P4 POP Stack IN PUSH Stack OUT
L n 0 -n: 0 v
integer L n 0 -n: 0 v
L n 0 -n: 0 v
L n 0 -n: 0 v
L n 0 -n: 0 v
L n 0 -n: 0 v
L n 0 -n: 0 v
L n t 0 -n: 0 v
L n 0 -n: 0 v
L n 0 -n: 0 v
R P1 P2 P3 P4 POP Stack IN PUSH Stack OUT
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
L n 0 -n: 0 -
R P1 P2 P3 P4 POP Stack IN PUSH Stack OUT
L n d 0 -n: 0 m
integer L n d 0 -n: 0 m
L n d 0 -n: 0 m
L n d 0 -n: 0 m
L n 0 -n: 0 m
L n 0 -n: 0 m
Push data Error Remark
lua_pushboolean bool bool push a boolean value
lua_pushinteger num push integer
lua_pushnumber num push Lua number (double)
lua_pushstring pc string push C string
lua_pushlstring pc len string push string of given length
lua_pushfstring pc fmt string push a sprintf() formatted string and return also pointer to result
lua_pushvfstring pc fmt va_list data push a vsprintf() formatted string and return also pointer to result
lua_pushcfunction cf func push a C function
lua_pushcclosure cf upvalue 1 func push a C closure with n upvalues (value 1 being pushed first)
upvalue n
lua_pushlightuserdata data data push light user data
lua_pushthread thread push the thread of the current stack, return 1 for main thread
lua_pushnil nil push nil
Check data Error Remark
lua_isboolean ok value return true if value at position n is a boolean
lua_isnumber ok value return true if value at position n is a number
lua_isstring ok value return true if value at position n is a string
lua_istable ok value return true if value at position n is a table
lua_isfunction ok value return true if value at position n is a Lua function
lua_iscfunction ok value return true if value at position n is a C function
lua_islightuserdata ok value return true if value at position n is a light user data
lua_isuserdata ok value return true if value at position n is a light/full user data
lua_isoneornil ok value return true if value at position n is nil or outside current stack
lua_isnone ok value return true if value at position n is outside current stack
lua_isnil ok value return true if value at position n is nil
lua_isthread ok value return true if value at position n is a thread
Get data checked Error Remark
luaL_checkany value check if value at position n is a valid value
luaL_checkinteger value check for integer and return int at position n
luaL_checkint int value check for number and return int at position n
luaL_checklong long value check for number and return long at position n
luaL_checkstring pc value check for string and return string at position n
luaL_checklstring pc plen value check for string and return string at position n and actual length
luaL_checknumber number value check for number and return int at position n
luaL_checktype value check for Lua type t at position n
luaL_checkudata data name value check for userdata name and return its pointer at position n
luaL_checkoption index pc ppc value search index of n (or pc) in list ppc
Get data converted Error Remark
lua_toboolean bool value convert value at position n to bool
lua_tocfunction cf value convert value at position n to a C function
lua_tointeger int value convert value at position n to integer
lua_tostring pc value convert value at position n to C string, return pointer
lua_tolstring pc plen value convert value at position n to C string, return pointer and actual length
lua_tonumber number value convert value at position n to a Lua number
lua_topointer data value convert value at position n to pointer
lua_tothread thread value convert value at position n to thread
lua_touserdata ud value convert value at position n to light userdata
Get data with defaults Error Remark
luaL_optint int value check for number at position n, return n if number or d otherwise
luaL_optinteger value check for number at position n, return n if number or d otherwise
luaL_optlong long value check for number at position n, return n if number or d otherwise
luaL_optnumber number value check for number at position n, return n if integer or d otherwise
luaL_optlstring string pc len value check for string at position n, return n if string or pc with len otherwise
luaL_optstring string pc value check for string at position n, return n if string or pc otherwise