mirror of https://github.com/axmolengine/axmol.git
Merge pull request #7029 from samuele3hu/v3_lua_ui_fix
Update `LuaStack::executeScriptFile` to support template project loading lua or luac files
This commit is contained in:
commit
19fa4733c5
|
@ -255,27 +255,10 @@ int LuaStack::executeString(const char *codes)
|
|||
|
||||
int LuaStack::executeScriptFile(const char* filename)
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
std::string code("require \"");
|
||||
code.append(filename);
|
||||
code.append("\"");
|
||||
return executeString(code.c_str());
|
||||
#else
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename);
|
||||
++_callFromLua;
|
||||
int nRet = luaL_dofile(_state, fullPath.c_str());
|
||||
--_callFromLua;
|
||||
CC_ASSERT(_callFromLua >= 0);
|
||||
// lua_gc(_state, LUA_GCCOLLECT, 0);
|
||||
|
||||
if (nRet != 0)
|
||||
{
|
||||
CCLOG("[LUA ERROR] %s", lua_tostring(_state, -1));
|
||||
lua_pop(_state, 1);
|
||||
return nRet;
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int LuaStack::executeGlobalFunction(const char* functionName)
|
||||
|
|
Loading…
Reference in New Issue