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)
|
int LuaStack::executeScriptFile(const char* filename)
|
||||||
{
|
{
|
||||||
std::string code("require \"");
|
CCAssert(filename, "CCLuaStack::executeScriptFile() - invalid filename");
|
||||||
code.append(filename);
|
|
||||||
code.append("\"");
|
FileUtils *utils = FileUtils::getInstance();
|
||||||
return executeString(code.c_str());
|
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)
|
int LuaStack::executeGlobalFunction(const char* functionName)
|
||||||
|
|
Loading…
Reference in New Issue