Many newcomers confuse these terms:
| Disassembly | Decompilation |
|----------------|------------------|
| Converts bytecode to a low-level, human-readable opcode representation (e.g., GETGLOBAL 0 1) | Reconstructs high-level Lua source code (local x = math.abs(-5)) |
| Always possible, even with stripped binaries | Often imperfect due to lost variable names, control flow obfuscation, or compiler optimizations |
| Useful for analyzing exact VM instructions | Useful for editing, understanding logic, or re-using code |
A decompiler internally disassembles first, then applies control flow analysis (loops, if-then-else) and expression reconstruction. decompile luac
Scenario: A game modder named Alex lost the source of a Lua AI script for a strategy game. Only ai.luac remains (Lua 5.2 with debug stripped).
Steps:
Use a hex editor or command-line tool:
xxd script.luac | head -n 1
Output example:
00000000: 1b4c 7561 5101 ... (0x51 = Lua 5.1)
Lua version mapping: