Optimizing Lua String Literals to Save 400 Bytes in ComputerCraft

Optimizing Lua string literals to save 400 bytes

7ibobev💬 0

My girlfriend and I faced a disk space crisis for our ComputerCraft programs, where our Lua code simply wouldn't fit on in-game diskettes. To solve this, we developed a clever compression strategy using raw strings and a custom bit-packing scheme to handle carriage returns efficiently. This approach allowed us to create a self-decompressing archive, saving crucial bytes while keeping the installation process simple for users.

"Cobalt folds newline sequences into single LF in raw strings, which is like running dos2unix on your PNG and expecting it not to be corrupted afterwards."

More from this day · 2026-07-16