lua-users home
lua-l archive

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


The following code works. But I don't understand why. That drives me nuts.

int ChildClass::index(lua_State* L)
{
    const char* key = luaL_checkstring(L, 2);
    lua_getmetatable(L, 1);
    lua_getfield(L, -1, key);
    if(lua_isnil(L, -1))
    {
        luaL_getmetatable(L, Base::classId);
        lua_getfield(L, -1, key);
    return 1;
}