只需lua_pushvalue(L, -2) 即可
-2 就是 相对table的位置
void FSLuaChannel::call_local_method( const FSMethod* method, FSParams* params ){ auto engine = cocos2d::LuaEngine::getInstance(); cocos2d::ScriptEngineManager::getInstance()->setScriptEngine(engine); lua_State* L = engine->getLuaStack()->getLuaState(); lua_getglobal(L, "_global_channels"); int top = lua_gettop(L); if(lua_istable(L, -1)){ lua_getfield(L, -1, this->uuid().c_str()); if(lua_istable(L, -1)){ lua_getfield(L, -1, method->name().c_str()); if(lua_isfunction(L, -1)){ lua_pushvalue(L, -2); __push_params(L, params, false, false); lua_pcall(L, 1 + params->size(), 0, 0); } } } lua_settop(L, top);
原文地址:http://blog.csdn.net/frodo_sens/article/details/45914755