lua-users home
lua-l archive

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

I could do with a bit of help please to point me in the right direction on a Lua chunk loading problem.
I initially had a nice simple load a lua program                 (just uncompiled ASCII text file)
loadResult = luaL_loadfile(L, "myLuaProg.lua");

Then I decided I wanted to store the lua program text in the C code, so I wrote an external utility program that turned "myLuaProg.lua" into a simple C lookup table source file. Once that C file was compiled into my App, I then Iused this to load it

loadResult = luaL_loadstring(L, myLuaProg_C);   // load the text from a simple C lookup table
So far so good that all worked fine, but then I wanted to precompile myLuaProg.lua into bytecode before I ran it through the utility to convert it to a C lookup table source file.
To load the compiled program from the C lookup table I dont think I can use the luaL_loadstring() function, so I changed that to be
loadResult = luaL_loadbuffer (L, myLuaProg_C, sizeof(myLuaProg_C), "myProg"); // load the bytecode from a simple C lookup table
This didnt crash, it returns 0 OK, but the code does nothing. I am guessing I am misunderstanding this and using the wrong function here ?
Any thoughts would be appreciated. Thanks