lua-users home
lua-l archive

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


Hello,
If I want to use Lua 4.0 and will pass C structure to Lua,
how should I do ?
I am doing the code like this:
struct {
	int red;
	int green;
	int blue;
} aTest;

lua_pushnumber(L, 1);
lua_pushnumber(L, aTest.red);

lua_pushnumber(L, 2);
lua_pushnumber(L, aTest.green);

lua_pushnumber(L, 3);
lua_pushnumber(L, aTest.blue);

lua_settable(L, 1);

I get an error in lua_settable(L, 1).
It seems that the index is wrong.
Can anyone tell me how to do?

Honglei