【发布时间】:2014-11-02 22:17:40
【问题描述】:
我真的不确定在 Lua 的 C API 中处理表。 我目前正在开发的界面需要我阅读 给我的 c 函数的表的内容:
example.lua:
myVector2 = {["x"]=20, ["y"]=30}
setSomePosition(myVector2)
我注册为“setSomePosition”的C函数:
static int lSetSomePosition(lua_State *L)
{
//number of arguments
if(lua_gettop(L) != 1)
{
//error handling
return 0;
}
//Need your help with the following:
//extract tables values of indexes "x" and "y"
return 0;
}
我知道有几种处理表格的方法,有时您需要知道我所做的索引。我现在对此感到困惑,我研究得越多,我就越困惑。可能是因为我真的不知道如何用适当的术语来描述我所追求的。
非常感谢一些很好的注释示例代码,说明您将如何填补我的 c 函数中的空白:)
(如果您对此主题有易于理解的指南,请不要介意评论)
【问题讨论】: