+ -
当前位置:首页 → 问答吧 → [Lua] 请问怎么修改table的值??

[Lua] 请问怎么修改table的值??

时间:2011-10-11

来源:互联网

-- test.lua
mytable = { x = "abc", child = { a=1, b=2 } }

1:请问如何修改x的值?
我按如下方法操作,结果不起作用:
lua_getglobal(L, "mytable");
lua_pushnumber(L, 1);
lua_pushstring(L, "abc");
lua_settable(L, -3);
到底要怎么写?

2:怎么改child的a的值??

作者: weiwuyuan   发布时间: 2011-10-11

试下lua_setfield。

作者: iambic   发布时间: 2011-10-11

我还是慢慢查吧

作者: weiwuyuan   发布时间: 2011-10-11