mirror of https://github.com/axmolengine/axmol.git
execute script with full file path
This commit is contained in:
parent
ca932a38e4
commit
24648db2b5
|
@ -274,10 +274,20 @@ int LuaStack::executeString(const char *codes)
|
|||
|
||||
int LuaStack::executeScriptFile(const char* filename)
|
||||
{
|
||||
std::string code("require \"");
|
||||
code.append(filename);
|
||||
code.append("\"");
|
||||
return executeString(code.c_str());
|
||||
CCAssert(filename, "CCLuaStack::executeScriptFile() - invalid filename");
|
||||
|
||||
FileUtils *utils = FileUtils::getInstance();
|
||||
std::string fullPath = utils->fullPathForFilename(filename);
|
||||
Data data = utils->getDataFromFile(fullPath);
|
||||
int rn = 0;
|
||||
if (!data.isNull())
|
||||
{
|
||||
if (luaLoadBuffer(_state, (const char*)data.getBytes(), (int)data.getSize(), fullPath.c_str()) == 0)
|
||||
{
|
||||
rn = executeFunction(0);
|
||||
}
|
||||
}
|
||||
return rn;
|
||||
}
|
||||
|
||||
int LuaStack::executeGlobalFunction(const char* functionName)
|
||||
|
|
Loading…
Reference in New Issue