lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Roger D Vargas wrote:
I was  using luaL_loadbuffer to execute scripts loaded from a file, with
good results, excepting that I couldnt use comments because all file was
passed as a single line.
So, i tried to change the code to use luaL_loadfile:

    if (filename.length() > 0) {
        int error = luaL_dofile(luaVM, filename.c_str())
            || lua_pcall(luaVM, 0, 0, 0);
            if (error) {
                cout << lua_tostring(luaVM, -1) << endl;
                lua_pop(luaVM, 1);

But this causes a lot of errors on script that worked perfectly with
previous version. What am I doing wrong here?

Are you aware that luaL_dofile() is defined as follows?

#define luaL_dofile(L, fn) \
	(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))

 - Peter Odding