added level in new format to repo

This commit is contained in:
binarycat 2022-03-16 14:21:35 -04:00
parent fa4b2c86b5
commit 577b7576cf
6 changed files with 13 additions and 51 deletions

View File

@ -15,7 +15,7 @@ end
function Chunk:getExportList() function Chunk:getExportList()
local r = {} local r = {}
for chunk in pairs(self.all) do for chunk in pairs(self.all) do
table.insert(r, chunk) table.insert(r, {chunk.filename, chunk.box})
end end
return r return r
end end
@ -46,6 +46,6 @@ function Chunk:load()
end end
function Chunk:save(chunkdir) function Chunk:save(chunkdir)
love.filesystem.write(chunkdir.."/chunks/"..self.filename, "return "..serialize_lua_data(self.data)) return love.filesystem.write(chunkdir.."/"..self.filename, "return "..serialize_lua_value(self.data))
end end

View File

@ -38,11 +38,13 @@ function exportLevel(levelname, dirname)
logPrint("Saving chunks...") logPrint("Saving chunks...")
local chunkdir = dirname.."/chunks" local chunkdir = dirname.."/chunks"
love.filesystem.createDirectory(chunkdir) love.filesystem.createDirectory(chunkdir)
for chunk in Chunk.all do for chunk in pairs(Chunk.all) do
chunk:save(chunkdir) local ok, err = chunk:save(chunkdir)
if not ok then error(err) end
end end
logPrint("Exporting complete.") logPrint("Exporting complete.")
else else
-- TODO: clean up created files
logPrint("Exporting failed: "..err) logPrint("Exporting failed: "..err)
end end
end end

View File

@ -1,6 +1,6 @@
function loadLevelTiles() function loadLevelTiles()
math.randomseed(3) math.randomseed(3)
level_current = love.filesystem.getSaveDirectory().."/export/test1" level_current = "data/levels/level1"
LevelData = dofile(level_current.."/level.lua") LevelData = dofile(level_current.."/level.lua")
LoadedObjects.Collisions = {} LoadedObjects.Collisions = {}
LoadedObjects.Platforms = {} LoadedObjects.Platforms = {}
@ -19,7 +19,7 @@ function loadLevelTiles()
local global_chunk = next(Chunk.all) local global_chunk = next(Chunk.all)
global_chunk:load() global_chunk:load()
LoadedObjects.Collisions = global_chunk.loaded.collisions LoadedObjects.Collisions = global_chunk.loaded.collisions
LevelTiles = global_chunk.data.tiles
--[[ --[[
on level format: on level format:
@ -31,12 +31,12 @@ function loadLevelTiles()
type = collision type type = collision type
]] ]]
LevelTiles = LevelData.tiles
updateLevelDimensions() updateLevelDimensions()
-- --
--createTileObjects() --createTileObjects()
createRoomObjects() --createRoomObjects()
getSpawns() --getSpawns()
end end
function createRoomObjects() function createRoomObjects()

View File

@ -1,42 +0,0 @@
return {
name = "Dev Level",
tileset = tileset.library,
properties = {
darkness = false
},
tiles = {
{ 1, 4, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{ 1, 4, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{ 1, 4, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{ 1, 4, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{ 1, 4, 0, 0, 0, 2, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14},
{ 1, 4, 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},
{ 1, 4, 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},
{ 1, 4, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 1, 1, 1, 1, 1, 1, 1, 4, 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},
{ 1, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13},
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = {
spawns = {
{Fairy,{100,88}},
{HookAnchor,{200,89,100}},
{HookAnchor,{400,89,120}}
},
rooms = {
{{96,64},{544,320}},
{{0,0},{112,176}}
},
},
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
return {[ [[tileset]] ]=[[library]],[ [[chunks]] ]={[ 1 ]={[ 1 ]=[[global.lua]],},},[ [[name]] ]=[[unnamed]],[ [[properties]] ]={[ [[darkness]] ]=false,},}