lua-users home
lua-l archive

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


>If I want to use Lua 4.0 and will pass C structure to Lua,
>how should I do ?

I assume you want to create a table that mirrors the C struct.
Int this case, the code is:

lua_newtable(L);
lua_pushstring(L,"red"); lua_pushnumber(L,aTest.red); lua_settable(L,-3);
lua_pushstring(L,"green"); lua_pushnumber(L,aTest.green); lua_settable(L,-3);
lua_pushstring(L,"blue"); lua_pushnumber(L,aTest.blue); lua_settable(L,-3);

The table is left on the top of the stack.
--lhf