作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
到目前为止,这就是我所拥有的...它创建了名为“mod”的全局表,但是我似乎无法向该表添加索引...
lua_newtable(L);
lua_setglobal(L,"mod");
最佳答案
manual说:
void lua_setfield (lua_State *L, int index, const char *k);
Does the equivalent to
t[k] = v
, wheret
is the value at the given valid index andv
is the value at the top of the stack.This function pops the value from the stack.
lua_setfield
。例如:
lua_pushnumber( L, 42 );
lua_setfield( L, -2, "answer_to_life_universe_and_rest" )
42
的字段“answer_to_life ...”插入表中。
关于api - 如何在Lua中创建表,然后从C API添加值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4220748/
我是一名优秀的程序员,十分优秀!