lua-users home
lua-l archive

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




Peter Odding escribió:
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?
No, I was using an example of luaL_loadbuffer as base for that code. I thought it was a function, not a macro.
So, i guess the correct code is
int error = luaL_dofile(luaVM, filename.c_str())
             if (error) {
                 cout << lua_tostring(luaVM, -1) << endl;
                 lua_pop(luaVM, 1);
             }
--
http://dsgp.blogspot.com | Linux, programación, juegos
Have no place I can be since I found Serenity
But you can’t take the sky from me

		
______________________________________________ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com