-- tools/fixtures/_ldtk_encode: run by tools/fixtures/ldtk.py (luau CLI, repo root): decodes every LDtk case (external -- levels through resolve) and writes it with our encoder, printing "\t" lines for Python to summarise. local Ldtk = require("@rosetta/vector/ldtk") local Bytes = require("@rosetta/core/Bytes") local Fx = require("@tests/gen/ldtk") local HEX = {} for i = 0, 255 do HEX[i] = string.format("%02x", i) end local function hex(s: string): string return (string.gsub(s, ".", function(c: string): string return HEX[string.byte(c)] end)) end for _, c in Fx.cases do local map = Ldtk.decode(Bytes.reader(buffer.fromstring(c.data)), { resolve = function(p: string): buffer? local f = c.files[p] return if f then buffer.fromstring(f) else nil end, }) if map then local out = Ldtk.encode(map) if out then print(c.name .. "\t" .. hex(buffer.tostring(out))) end end end