Created
January 7, 2016 20:14
-
-
Save TannerRogalsky/61e1654a96d133c7c9b3 to your computer and use it in GitHub Desktop.
Load encoded/compressed Tiled data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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