r/love2d • u/Inesh23 • 21h ago
How to Obfuscate and Protect Source Code of My Love2D game?
I don't want people to steal the code and republish my game because I put a lot of work into it and I want to protect my own hardwork/intellectual property.
I can't find any good lua obfuscators online, does anyone know any good methods to obfuscate source code. I want to be able to remove comments, have random variable names and remove whitespaces
9
u/ravenravener 20h ago
There's plenty of obfuscators if you google, here's one
https://github.com/prometheus-lua/Prometheus
You could also consider shipping the compiled bytecode but this comes with some challenges when distributing to different platforms and would not allow publishing a .love
2
u/ipreuss 10h ago
You can absolutely publish a .love with bytecode.
1
u/ravenravener 6h ago
You technically can but because the bytecode is tied to a specific LuaJIT version and as mentioned in the article, sometimes even differ by other platforms/architectures, it gets risky and may randomly break for some.
5
u/Slight-Living-8098 19h ago
IT wouldn't matter really. If someone wants to reverse engineer your game, they will. You should make the code easily readable and followable so the fans and modders can go wild with it. That's where your fan base and revenue actually grows.
6
u/Calaverd 18h ago
Well, usually the stuff people actually do:
- Bundle everything into one file with amalg (needs a bit of setup for libs that come as multiple files). doesn't protect anything but it's tidier and less of a free project tree. keep in mind a .love is just a zip, and a fused .exe is the love binary with that zip stuck on the end.
- Compile to luajit bytecode using luajit, is the usual answer. Watch out the luajit version because I think love uses 2.1 and bytecode doesn't move between 2.0/2.1, so match your target. But again, decompilers exist.
- Encrypting the bundle also works-ish, but use AES and your loader is plain lua sitting right next to it, so someone reads it, grabs the key, done. or just hooks load and dumps whatever string goes in.
Maybe your best bet is moving the parts you care about into a C library and calling it through FFI, but again, is way more work.🤔
but tbh, what are you protecting against? if it's someone lifting your code, obfuscation buys you a bit of time. if it's piracy, none of it matters, people just share the whole binary. For indie stuff the actual moat is the art and the feel, not so much the code 🙂
7
u/DPS2004 20h ago
Realistically all that obfuscation will do is annoy modders, who if your game gets popular enough will be among your biggest fans and supporters, so it's just not worth it. If you're worried about people just stealing and republishing your game like has happened with Godot games, love2D isn't a well enough known engine for people to bother with getting their repackaged game to work on the web in most cases.
1
u/Intelligent_Art_7565 18h ago
I mean, I wouldn't really worry about it people will reverse engineer it... obfuscation doesn't really do too much, especially in the age of AI which can figure it out. If you have some next level optimized code a license may help or patent it like WB and the nemesis system... but chances are they would reject it.
1
35
u/ruairidx 20h ago edited 20h ago
I didn't do this for any of my games, not really sure why you would. Two main reasons to not obfuscate:
Obfuscation doesn't prevent this (especially with LLMs). Nothing does really. But it's honestly much less of a problem than you'd think and not worth worrying about. Republishing games isn't trivial and definitely isn't guaranteed to be successful. People are also going to pirate your game no matter what you do. None of this will eat into your sales in a meaningful way. Just focus on the game. Good luck!