Return to Snippet

Revision: 9933
at November 30, 2008 21:24 by mjsmagalhaes

Initial Code
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"

int main()
	// Create a context. This stores all variables and function available to Lua.
	lua_State * execContext = luaL_newstate();
	// Adding Lua basic library
	// Pushing the print function to the stack
	lua_getfield(execContext, LUA_GLOBALSINDEX, "print");
	// Adding the first argument to the print function
	lua_pushstring(execContext,"Hello World !");
	// print "Hello World !"
	// the state, number of args, number of returned values
	// Cleaning the house

Initial URL

Initial Description
This is a hello world and the first of a series that shows how to embed Lua in a C/C++ application.

Initial Title
Hello World Using Lua Api

Initial Tags

Initial Language