lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>Im very new to this, and I would like to know (with some minimal example if 
>posible), how to execute a lua script from my C++ app and make it modify 
>variables.

Execute a script with lua_dofile. Read and write variables with lua_getglobal
and lua_setglobal.

Here is a simple example:

-- script hi.lua

print(name)

-- C code

	lua_dofile(L,"hi.lua");		/* outputs "nil" */
	lua_pushstring(L,"John Lennon");
	lua_setglobal(L,"name");
	lua_dofile(L,"hi.lua");		/* outputs "John Lennon" */

Hope it helps you get started.
--lhf