I'm writing a basic scripting system using lua in C++. One of my glue functions is...
lua_register(luaVM, "openFile", l_dial.l_specifyF);
The function is as follows.
static int l_specifyF(lua_State* luaVM) {
const char* c = lua_tostring(luaVM, -1);
cDialogManager::getSingletonPtr()->clearVector();
try{
luaL_dofile(luaVM, c);
} catch(...) {
cout << "Unable to open file" << endl;
luaL_dofile(luaVM, "startup.lua");
}
return 1;
}
When I call it inside the program it will be 100% fine if I call a file in the local folder like openFile("somefile.lua")
or openFile("someotherfile.lua")
but will crash when calling files located in other folders such as openFile("scripts/ohdear.lua")
. (As a sidenote this does actually work on some occasions, which only adds to the confusion.) Any reason why this might be?