Page 1 of 1

Lua binary files?

Posted: Fri Oct 14, 2011 11:29 am
by infinte
Hi.
I'm thinking about a problem in destribution. Does love2d support lua "binery code"s generated by luac?
thanks.

Re: Lua binary files?

Posted: Fri Oct 14, 2011 11:40 am
by ivan
It probably does. Lua's virtual machine executes both compiled and non-compiled code alike.
Are you sure your luac.exe output is correct?

Re: Lua binary files?

Posted: Fri Oct 14, 2011 11:45 am
by infinte
ivan wrote:It probably does. Lua's virtual machine executes both compiled and non-compiled code alike.
Are you sure your luac.exe output is correct?
I've compiled a lua file (library-level, .lua) into binary (.b) and love cannot require it.

Re: Lua binary files?

Posted: Fri Oct 14, 2011 12:12 pm
by miko
infinte wrote:
ivan wrote:It probably does. Lua's virtual machine executes both compiled and non-compiled code alike.
Are you sure your luac.exe output is correct?
I've compiled a lua file (library-level, .lua) into binary (.b) and love cannot require it.
It needs the *.lua extension, unless you modify package.path. BTW, it will not work if the love was compiled with luajit (or: bytecode generated by lua and luajit are not interchangeable).

Re: Lua binary files?

Posted: Fri Oct 14, 2011 12:26 pm
by infinte
miko wrote:
infinte wrote:
ivan wrote:It probably does. Lua's virtual machine executes both compiled and non-compiled code alike.
Are you sure your luac.exe output is correct?
I've compiled a lua file (library-level, .lua) into binary (.b) and love cannot require it.
It needs the *.lua extension, unless you modify package.path. BTW, it will not work if the love was compiled with luajit (or: bytecode generated by lua and luajit are not interchangeable).
Changing `package.path` works! thanks.

Re: Lua binary files?

Posted: Fri Oct 14, 2011 1:27 pm
by bartbes
That is not a solution, since love ignores package.path, so when properly packaged it won't work. Instead, just name them with a lua extension. This, of course, raises the question why you would do such a thing in the first place.

Re: Lua binary files?

Posted: Fri Oct 14, 2011 3:54 pm
by kikito
infinte wrote:Hi.
I'm thinking about a problem in destribution. Does love2d support lua "binery code"s generated by luac?
thanks.
Using compiled lua bytecode doesn't help distribution - Pretty much the opposite; your .love file isn't guaranteed to work in all platforms.

Your problem probably has to do more with encryption than distribution. Luac alone will not help you on that regard; there's a standard decompiler, called luaDec51, which will easily undo the compiling.