C 调用 LUA时候如何push table self

只需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);

,我想去旅行,一个人背包,一个人旅行,

C 调用 LUA时候如何push table self

相关文章:

你感兴趣的文章:

标签云: