Tiled Exports Lua files
Posted: Tue Jan 29, 2013 5:34 am
During the most recent Global Game Jam, a teammate of mine noticed that if you do the "Export As" option from the File menu in Tiled, that you can export your maps directly as Lua files. I hadn't even seen this before, nor have I heard about it on the forums, so I just thought I might as well let everyone know. Here is a sample (pasted directly from the file, so no nice formatting):
It doesn't seem to output in anything other than CSV (unlike normal .tmx files which can output using Base64 encoding and zlib/gzip compression), but beyond that, this seems like a nice alternative to often bulky XML parsers.
Code: Select all
return { version = "1.1", luaversion = "5.1", orientation = "orthogonal", width = 40, height = 11, tilewidth = 16, tileheight = 16, properties = {}, tilesets = { { name = "MarioNES", firstgid = 1, tilewidth = 16, tileheight = 16, spacing = 0, margin = 0, image = "../CPP/testTiled/mariones.png", imagewidth = 304, imageheight = 192, properties = {}, tiles = {} } }, layers = { { type = "tilelayer", name = "Background", x = 0, y = 0, width = 40, height = 11, visible = true, opacity = 1, properties = {}, encoding = "lua", data = { 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 39, 40, 41, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 39, 40, 41, 44, 44, 44, 44, 44, 44, 44, 44, 58, 59, 60, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 39, 40, 41, 44, 44, 44, 44, 44, 44, 44, 44, 58, 59, 60, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 58, 59, 60, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 27, 44, 44, 44, 44, 44, 44, 44, 44, 44, 27, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 27, 44, 44, 44, 44, 44, 44, 44, 45, 46, 47, 48, 44, 44, 44, 44, 44, 44, 45, 46, 47, 48, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 46, 47, 48, 44, 44, 44, 44, 63, 64, 65, 66, 67, 44, 20, 21, 22, 44, 63, 64, 65, 66, 67, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 20, 21, 22, 44, 63, 64, 65, 66, 67, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44 } }, { type = "tilelayer", name = "Foreground", x = 0, y = 0, width = 40, height = 11, visible = true, opacity = 1, properties = {}, encoding = "lua", data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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