Petrichor.Bits#
require("Petrichor.Bits") implements 6-bit ASCII bit packing. Mods use it for compact settings strings and other binary payloads that need to survive copy and paste.
API#
| Function | Description |
|---|---|
Bits.CHARSET | 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_ |
Bits.toBits(n, width) | Integer to zero-padded binary string |
Bits.encode(bitString) | Binary string → 6-bit ASCII |
Bits.decode(encoded) | 6-bit ASCII → binary string |
Bits.decodeInt(encoded) | Single encoded character(s) → integer |
Bits.newProcessor(bits) | Stateful reader with :nextInt(n), :nextBool(), :remaining() |
Field layouts for a specific mod stay in that mod. This module only handles the shared encode and decode primitives.