"foo"); lua_pushinteger(L, 5); lua_pushinteger(L, 3); lua_call(L, 2, 1); // call a function with two arguments and one return value printf("Result: %d\n", lua_tointeger(L, -1)); // print integer value of item at stack top lua_pop(L, 1); // return stack to original state lua_close(L); // close Lua state return 0; } Running this example gives: $ cc -o example example.c -llua $ ./example Result: 8 The C API also provides some special tables, located at various "pseudo-indices" in the Lua stack. At LUA_GLOBALSINDEX prior to Lua 5.2 is the globals table, _G from within Lua, which is the main namespace. There is also a registry located at LUA_REGISTRYINDEX where C programs can store Lua values for later retrieval. Modules Besides standard library (core) modules it is possible to write extensions using the Lua API. Extension modules are shared objects which can be used to extend the functionality of the interpreter by providing native facilities to Lua scripts. Lua scripts may load extension modules using require, just like modules written in Lua itself, or with package.loadlib. When a C library is loaded via Lua will look for the function luaopen_foo and call it, which acts as any C function callable from Lua and generally returns a table filled with methods . A growing collection of modules known as rocks are available through a package management system called LuaRocks, in the spirit of CPAN, RubyGems and Python eggs. Prewritten Lua bindings exist for most popular programming languages, including other scripting languages. For C++, there are a number of template-based approaches and some automatic binding generators. Applications In video game development, Lua is widely used as a scripting language by programmers, mainly due to its perceived easiness to embed, fast execution, and short learning curve. Notable games which use Lua include Roblox, Garry's Mod, World of Warcraft, Payday 2, Phantasy Star Online 2, Dota 2, Crysis, and many others. Some games that do not natively support Lua programming or scripting, have this functionality added by mods, such as ComputerCraft does for Minecraft. In addition, Lua is also used in non-video game software, such as Adobe Lightroom, Moho, iClone, Aerospike and certain system software in FreeBSD and NetBSD, and is used as a template scripting language on MediaWiki using the Scribunto extension. In 2003, a poll conducted by GameDev.net showed Lua was the most popular scripting language for game programming. On 12 January 2012, Lua was announced