Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将多个表返回到C++;,如何知道返回的表名 我用Lua实现了一些函数,结果放在表 s>强中,并返回到C++代码中。例如,在Lua的末尾,我将这些表< /强>返回到C++ +/p> return names, ages, courses 现在C++中,我需要读取返回表中的元素。如何知道表的名称以便知道要检索哪些元素?换句话说,以下sudo代码说明了我想做的事情: if table_name == "names": //some commands can realize this? lua_getfield(L, -1, "Tom"); the_name = lua_tostring(L, -1); cout << the_name << endl; Lua_pop(L, 1); elif table_name == "ages": //similar to last comment... lua_getfield(L, -1, "girls"); the_age = lua_tostring(L, -1); ....... //some operations 如果table_name==“name”://一些命令可以实现这一点吗? 卢厄·格特菲尔德(L,-1,“汤姆”); _name=lua_tostring(L,-1); cout_C++_Lua_Lua Table - Fatal编程技术网

将多个表返回到C++;,如何知道返回的表名 我用Lua实现了一些函数,结果放在表 s>强中,并返回到C++代码中。例如,在Lua的末尾,我将这些表< /强>返回到C++ +/p> return names, ages, courses 现在C++中,我需要读取返回表中的元素。如何知道表的名称以便知道要检索哪些元素?换句话说,以下sudo代码说明了我想做的事情: if table_name == "names": //some commands can realize this? lua_getfield(L, -1, "Tom"); the_name = lua_tostring(L, -1); cout << the_name << endl; Lua_pop(L, 1); elif table_name == "ages": //similar to last comment... lua_getfield(L, -1, "girls"); the_age = lua_tostring(L, -1); ....... //some operations 如果table_name==“name”://一些命令可以实现这一点吗? 卢厄·格特菲尔德(L,-1,“汤姆”); _name=lua_tostring(L,-1); cout

将多个表返回到C++;,如何知道返回的表名 我用Lua实现了一些函数,结果放在表 s>强中,并返回到C++代码中。例如,在Lua的末尾,我将这些表< /强>返回到C++ +/p> return names, ages, courses 现在C++中,我需要读取返回表中的元素。如何知道表的名称以便知道要检索哪些元素?换句话说,以下sudo代码说明了我想做的事情: if table_name == "names": //some commands can realize this? lua_getfield(L, -1, "Tom"); the_name = lua_tostring(L, -1); cout << the_name << endl; Lua_pop(L, 1); elif table_name == "ages": //similar to last comment... lua_getfield(L, -1, "girls"); the_age = lua_tostring(L, -1); ....... //some operations 如果table_name==“name”://一些命令可以实现这一点吗? 卢厄·格特菲尔德(L,-1,“汤姆”); _name=lua_tostring(L,-1); cout,c++,lua,lua-table,C++,Lua,Lua Table,您不知道以前存储表的变量名,但是您的Lua函数会按特定顺序返回它们。在C++中,这些表放在堆栈上,所以课程是最高值,代码> AGE/下一个。 < p>在所有表中都有一个字段,包含它们的名称/类型。在所有表中都有一个字段,包含它们的名称/类型。@ MalHoRopaTeEk听起来不错!我将添加它作为答案。与所有Lua值一样,表没有名称。变量有名字。嗯…似乎有点不对劲…看这里是我的代码;

您不知道以前存储表的变量名,但是您的Lua函数会按特定顺序返回它们。在C++中,这些表放在堆栈上,所以<代码>课程是最高值,<>代码> AGE/<代码>下一个。

< p>在所有表中都有一个字段,包含它们的名称/类型。

在所有表中都有一个字段,包含它们的名称/类型。@ MalHoRopaTeEk听起来不错!我将添加它作为答案。与所有Lua值一样,表没有名称。变量有名字。嗯…似乎有点不对劲…看这里是我的代码;