Pre-compiling files

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
hlship
Prole
Posts: 11
Joined: Mon Dec 05, 2011 8:39 pm

Pre-compiling files

Post by hlship »

From what I can see of the love2d source, it appears that Love really wants the Lua source in source form, since it looks inside the .love file for specific files, such as "conf.lua" and "main.lua".

I'm curious if there is any thought towards pre-compiling the Lua code via luac and somehow packaging that into the .love file?

I doubt there would be any use to it besides some obfuscation of the game source (the compiled lua bytecode is often the same size, or larger, than the corresponding lua source, at least, if debugging symbols are left in place).
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Pre-compiling files

Post by slime »

You can precompile your Lua files using luac and rename them to .lua and it will work fine on your computer, however luac probably won't work between Lua versions and different architectures (x86 vs x64). If you use love with LuaJIT, its compiled files will work between different architectures I believe, but again not between different versions.
User avatar
Xgoff
Party member
Posts: 211
Joined: Fri Nov 19, 2010 4:20 am

Re: Pre-compiling files

Post by Xgoff »

also, bytecode is... not safe

in terms of obfuscation it doesn't really help either since the bytecode format has been quite well documented and since you can get a disassembly from luac, if people really want your game's source then they could just as well reconstruct it based on that (or find a lua decompiler that doesnt choke on it)

afaik the only real benefit bytecode gives is improved loading time (which is probably going to be completely marginal unless your source files are huge), and that it means you can compile lua without the parser/compiler which is really only interesting if you need to reduce the size of the vm for embedded hardware

so there probably isnt much point in bytecode for general use

bytecode is probably somewhat more attractive for luajit since it has the ability to dump it in various formats which make it easier to embed into c source (and i believe its require is aware of this)
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: Pre-compiling files

Post by miko »

hlship wrote: I'm curious if there is any thought towards pre-compiling the Lua code via luac and somehow packaging that into the .love file?
Search forum for "luac" ("Search" in the top right of the page)
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Pre-compiling files

Post by coffee »

hlship wrote:From what I can see of the love2d source, it appears that Love really wants the Lua source in source form, since it looks inside the .love file for specific files, such as "conf.lua" and "main.lua".

I'm curious if there is any thought towards pre-compiling the Lua code via luac and somehow packaging that into the .love file?

I doubt there would be any use to it besides some obfuscation of the game source (the compiled lua bytecode is often the same size, or larger, than the corresponding lua source, at least, if debugging symbols are left in place).
Not very interested in this compiling/obfuscation theme but If you wan't install Lua / mess with luac and just for see the results you can try this online compiler. It return a precompiled lua file (Please spare me for the couldn't work because of bytecoding rant or that someone can rob your code in this way. Just being helpful).
http://mta.dzek.eu/compiler/

BTW what advantages have that LuaJIT you keep talking about? Have the same pre-compiling purpose of Luac or you will need to distribute LuaJIT along for realtime-processing?
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Pre-compiling files

Post by MarekkPie »

I am by NO MEANS an expert, but it has something to do with the JIT part.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Pre-compiling files

Post by bartbes »

Fun fact, at one time love had a distribution problem because it used luac versions of its internal scripts.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Pre-compiling files

Post by Robin »

bartbes wrote:Fun fact, at one time love had a distribution problem because it used luac versions of its internal scripts.
When was this?
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Pre-compiling files

Post by bartbes »

I don't quite remember, not too long ago, though.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 78 guests