Logged level export

This commit is contained in:
lustlion 2022-02-08 08:40:17 +01:00
parent 1f7d967f77
commit e7aa34d5c2
1 changed files with 9 additions and 0 deletions

View File

@ -3,15 +3,21 @@ function ExportLevel(levelname)
local success, message = love.filesystem.write(filename, "") local success, message = love.filesystem.write(filename, "")
if success then if success then
love.filesystem.append(filename, "return {") love.filesystem.append(filename, "return {")
logPrint("Exporting level \"".. filename .. "\"...")
love.filesystem.append(filename, "\n name = \"" .. levelname .. "\",") love.filesystem.append(filename, "\n name = \"" .. levelname .. "\",")
logPrint("- level name")
for k, v in pairs(tileset) do for k, v in pairs(tileset) do
if v == LevelData.tileset then if v == LevelData.tileset then
love.filesystem.append(filename, "\n tileset = tileset." .. k .. ",") love.filesystem.append(filename, "\n tileset = tileset." .. k .. ",")
logPrint("- tileset")
end end
end end
love.filesystem.append(filename, "\n tiles = {") love.filesystem.append(filename, "\n tiles = {")
logPrint("- tiles")
local rows = #LevelTiles
for i = 1, #LevelTiles do for i = 1, #LevelTiles do
love.filesystem.append(filename, "\n { ") love.filesystem.append(filename, "\n { ")
logPrint(" - Row "..i.."/"..rows.." "..math.floor(100*((i-1)*100/rows))/100 .."%")
for j = 1, #LevelTiles[i] do for j = 1, #LevelTiles[i] do
if j ~= 1 then if j ~= 1 then
love.filesystem.append(filename, ", ") love.filesystem.append(filename, ", ")
@ -23,9 +29,12 @@ function ExportLevel(levelname)
love.filesystem.append(filename, ", ") love.filesystem.append(filename, ", ")
end end
end end
logPrint(" - All rows 100%")
love.filesystem.append(filename, "\n },") love.filesystem.append(filename, "\n },")
love.filesystem.append(filename, "\n objects = {}") love.filesystem.append(filename, "\n objects = {}")
logPrint("- objects")
love.filesystem.append(filename, "\n}") love.filesystem.append(filename, "\n}")
logPrint("Exporting complete.")
end end
end end