// 创建二维数组Lua表
void createLuaTable2(lua_State *L, const char* t)
{
lua_newtable(L); // t
//========================
lua_pushinteger(L, 1); // t[1]
lua_newtable(L); // p1
// p1[1] = 100
lua_pushinteger(L, 1);
lua_pushinteger(L, 100);
lua_settable(L, 3);
// p1[2] = 200
lua_pushinteger(L, 2);
lua_pushinteger(L, 200);
lua_settable(L, 3);
// p1[3] = 300
lua_pushinteger(L, 3);
lua_pushinteger(L, 300);
lua_settable(L, 3);
// t[1] = p1
lua_settable(L, 1);
//==========================
lua_pushinteger(L, 2); // t[2]
lua_newtable(L); // p2
// p2[1] = 'AAAA'
lua_pushinteger(L, 1);
lua_pushstring(L, "AAAA");
lua_settable(L, 3);
// p2[2] = 'BBBB'
lua_pushinteger(L, 2);
lua_pushstring(L, &#
在C中创建二维Lua表示例
最新推荐文章于 2023-12-02 09:56:16 发布