Level list now pulled from "levels", changed log stuff.

This commit is contained in:
bizcochito 2022-02-08 11:30:59 +01:00
parent 2f19554279
commit cbcf90de2d
3 changed files with 24 additions and 6 deletions

View File

@ -41,6 +41,18 @@ function ExportLevel(levelname, filename)
end
end
-- Source https://stackoverflow.com/a/11130774
function scandir(directory)
local i, t, popen = 0, {}, io.popen
local pfile = popen('ls "'..directory..'"')
for filename in pfile:lines() do
i = i + 1
t[i] = filename
end
pfile:close()
return t
end
--[[
return {
name = "level1",
@ -57,6 +69,8 @@ return {
objects = {}
}
]]
if logging then
-- Make log stuff
os.execute( "mkdir \"./Mothback/logs\"" )
logFile = io.open("Mothback/logs/mothback_"..os.date("%Y-%m-%d_%H-%M-%S")..".log", "a+")
end

View File

@ -1,6 +1,6 @@
function LevelLoadTiles()
LevelData = dofile("Mothback/data/levels/"..currLevel..".lua")
LevelData = dofile("Mothback/data/levels/"..currLevel)
--[[
on level format:

View File

@ -1,6 +1,7 @@
function love.load()
logging = true
if logging then print("love: "..collectgarbage("count").." kB") end
loveMemUsage = collectgarbage("count")
loveInitLog = "love: "..loveMemUsage.." kB, time: "..os.clock().." seconds"
arrow = 0
menu_type = "no"
@ -26,6 +27,8 @@ function love.load()
}
require "data/scripts"
logPrint(loveInitLog)
loveInitLog = nil
Canvas = {
Darkness = CreateDarkness()
}
@ -36,9 +39,10 @@ function love.load()
Camera.width = game.width
Camera.height = game.height
levelList = {"level1","2","3","ewae","tileset"}
levelList = scandir("./Mothback/data/levels")
levelNum = 1
currLevel = levelList[levelNum]
logPrint("currLevel: "..currLevel)
LoadedEntities = {}
LoadedParticles = {}
LevelLoadTiles()