mirror of https://github.com/axmolengine/axmol.git
Fix ComponentTest in la-test can not load lua file under iOS & Android
This commit is contained in:
parent
f76b941415
commit
3223a97b26
|
@ -139,7 +139,12 @@ bool ComponentLua::loadAndExecuteScript()
|
|||
lua_State *l = engine->getLuaStack()->getLuaState();
|
||||
|
||||
// load script
|
||||
int error = luaL_loadfile(l, _scriptFileName.c_str());
|
||||
auto fileUtils = FileUtils::getInstance();
|
||||
std::string fullPathOfScript = fileUtils->fullPathForFilename(_scriptFileName);
|
||||
Data data = fileUtils->getDataFromFile(fullPathOfScript);
|
||||
int error = LUA_ERRFILE;
|
||||
if(data.getSize() > 0)
|
||||
error = engine->getLuaStack()->luaLoadBuffer(l, (const char*)data.getBytes(), (int)data.getSize(), fullPathOfScript.c_str());
|
||||
if (error)
|
||||
{
|
||||
CCLOG("ComponentLua::loadAndExecuteScript: %s", lua_tostring(l, -1));
|
||||
|
|
Loading…
Reference in New Issue