【发布时间】:2016-02-15 05:20:20
【问题描述】:
我有一个问题,我想知道是否可以计算函数 lua_getglobal 中存在的设置。
我有一个叫做define.lua的文件他如下:
tbl {
macro_enable = true;
macro_value = 100;
time_expire = 60;
enable_mac = true;
};
我试图在我的代码中插入一条消息来计算存在设置的数量
代码:
lua_getglobal(L, "tbl");
lua_getfield(L, -1, "macro_enable");
p->macro_enable = lua_toboolean(L, -1);
lua_getfield(L, -1, "macro_value");
p->macro_value = lua_tointeger(L, -1);
lua_getfield(L, -1, "time_expire");
p->time_expire = lua_tointeger(L, -1);
lua_getfield(L, -1, "enable_mac");
p->enable_mac = lua_toboolean(L, -1);
想要添加消息。
printf ("% d configurations have been read");
我尝试多做一个循环,但没有成功
【问题讨论】:
标签: c loops for-loop lua lua-api