lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



In lua I assume your C++ method is bound to something like XX:GetList() :
 
-- Just use table constructor to put all your elements in a table
local elements = { XX:GetList() }
-- Iterate on it to access your elements
for key,val = ipairs(elements) do
    local i = val
    print(i)
end


De : lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] De la part de zichen1918@163.com
Envoyé : 6 juillet 2006 02:06
À : Lua list
Objet : Help

Hello,I meet a question:
In C++ Use luaWrapper:
int XX::GetList(lua_State* L)
{
    int nCount(0);
    for( int i = 1; i < MAX_NUM; ++i)
    {
        if(m_array[i] == TRUE)
        {
            lua_pushnumber(L, i)
            ++nCount;
        }
    }
    return nCount;
}
In lua, How Can I Get This List Elements?
 
thank!

子辰
2006-07-06

发件人: Brian Weed
发送时间: 2006-07-03 23:43:43
收件人: Lua list
抄送:
主题: no calling environment
 
 
After  recently  upgrading  to  Lua  v5.1.1,    I  am  now  getting  an  error  when  
trying  to  call  luaopen_io    (previously  known  as    lua_iolibopen):
 
luaopen_io- >lua_replace- >lua_G_runerror
 
lapi.c  line  203:  
 
/*  explicit  test  for  incompatible  code  */
if  (...)
       luaG_runerror(L,  "no  calling  environment")
 
Can  someone  tell  me  why  one  would  get  this  error?    I'm  not  messing  with  
environments  (not  on  purpose,  anyway).
 
Brian