Skip to content

Instantly share code, notes, and snippets.

@TannerRogalsky
Created January 7, 2016 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TannerRogalsky/61e1654a96d133c7c9b3 to your computer and use it in GitHub Desktop.
Save TannerRogalsky/61e1654a96d133c7c9b3 to your computer and use it in GitHub Desktop.
Load encoded/compressed Tiled data
-- From https://github.com/karai17/Simple-Tiled-Implementation/blob/4ac519dbd5efdc0c6a70c35b9125faebe347772f/map.lua#L217
local ffi = require("ffi")
local function getDecompressedData(data)
local d = {}
local decoded = ffi.cast("uint32_t*", data)
for i=0, data:len() / ffi.sizeof("uint32_t") do
table.insert(d, tonumber(decoded[i]))
end
return d
end
local s = 'eJzt1DEBAAAIw7D5F4kWXLCDREGvJgBMOwCgzAeB73wQ+M4HAQAAAAAAAAAAAAAAALi20GgDeQ=='
data = getDecompressedData(love.math.decompress(love.filesystem.newFileData(s, "data", "base64"):getString(), "zlib"))
print(#data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment