tags:

views:

41

answers:

1

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?

A: 

From your description I seriously doubt that it has something to do with folder struction. My guess is, that you are observing an late reaction from an earlier error...

towi
I think you are probably right, will have a root around and see if I can uncover the problem.
FortyVsZero