function ExportLevel(levelname, filename) filename = filename or "output.lua" exportFile = io.open(filename, "a+") local success, message = love.filesystem.write(filename, "") if success then exportFile:write("return {") logPrint("Exporting level \"".. levelname .. "\"...") exportFile:write("\n name = \"" .. levelname .. "\",") logPrint("- level name") for k, v in pairs(tileset) do if v == LevelData.tileset then exportFile:write("\n tileset = tileset." .. k .. ",") logPrint("- tileset") end end exportFile:write("\n tiles = {") logPrint("- tiles") local rows = #LevelTiles for i = 1, #LevelTiles do exportFile:write("\n { ") logPrint(" - Row "..i.."/"..rows.." "..math.floor(100*((i-1)*100/rows))/100 .."%") for j = 1, #LevelTiles[i] do if j ~= 1 then exportFile:write(", ") end exportFile:write(tostring(LevelTiles[i][j].id)) end exportFile:write("}") if i ~= #LevelTiles then exportFile:write(", ") end end logPrint(" - All rows 100%") exportFile:write("\n },") exportFile:write("\n objects = {}") logPrint("- objects") exportFile:write("\n}") logPrint("Exporting complete.") exportFile:close() end end --[[ return { name = "level1", tileset = tileset.library, tiles = { {13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13}, { 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, 5,25,26, 6,25,26, 7, 0, 5,25,26, 7, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 5,49,50, 6,49,50, 7, 0, 5,49,50, 7, 0, 0, 0, 0, 0, 0}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} }, objects = {} } ]] logFile = io.open("mothback_"..os.date("%Y-%m-%d_%H-%M-%S")..".log", "a+")