diff --git a/Zframework/bgm.lua b/Zframework/bgm.lua index fd7c6b4f..364b38e8 100644 --- a/Zframework/bgm.lua +++ b/Zframework/bgm.lua @@ -62,16 +62,20 @@ function BGM.init(list) Sources[name]:setLooping(true) Sources[name]:setVolume(0) return true - -- else - -- MES.new('warn',"[no BGM] "..Sources[name],5) + else + LOG("No BGM: "..Sources[name],5) end elseif Sources[name]then return true - -- elseif name then - -- MES.new('warn',"No BGM: "..name,5) + elseif name then + LOG("No BGM: "..name,5) + end + end + function BGM.loadAll()--Not neccessary, unless you want avoid the lag when playing something for the first time + for name in next,Sources do + _load(name) end end - function BGM.loadAll()for name in next,Sources do _load(name)end end function BGM.play(name) name=name or BGM.default if not _load(name)then return end diff --git a/Zframework/image.lua b/Zframework/image.lua index 61cedf65..260b9c6b 100644 --- a/Zframework/image.lua +++ b/Zframework/image.lua @@ -12,7 +12,7 @@ function IMG.init(list) elseif type(list[name])=='string'then self[name]=love.graphics.newImage(list[name]) else - MES.new('warn',"No IMG: "..name,5) + LOG("No IMG: "..name) self[name]=null end return self[name] diff --git a/Zframework/init.lua b/Zframework/init.lua index ea26c2ec..775f8007 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -30,6 +30,7 @@ do--Add pcall & MES for JSON lib end --Pure lua modules (complex) +LOG= require'Zframework.log' REQUIRE= require'Zframework.require' TASK= require'Zframework.task' WS= require'Zframework.websocket' diff --git a/Zframework/languages.lua b/Zframework/languages.lua index 60208b22..a4798236 100644 --- a/Zframework/languages.lua +++ b/Zframework/languages.lua @@ -33,6 +33,10 @@ function LANG.init(defaultLang,langList,publicText,pretreatFunc) end function LANG.get(l) + if not langList[l]then + LOG("Wrong language: "..tostring(l)) + l=defaultLang + end return langList[l] end diff --git a/Zframework/log.lua b/Zframework/log.lua new file mode 100644 index 00000000..b727064f --- /dev/null +++ b/Zframework/log.lua @@ -0,0 +1,19 @@ +local ins=table.insert + +local logs={os.date("Techmino logs %Y/%m/%d %A")} + +local function log(message) + ins(logs,os.date("%H:%M:%S")..message) +end + +local LOG=setmetatable({logs=logs},{ + __call=function(_,message) + log(message) + end +}) + +function LOG.read() + return table.concat(logs,"\n") +end + +return LOG \ No newline at end of file diff --git a/Zframework/sfx.lua b/Zframework/sfx.lua index 3a09cf56..81aae38a 100644 --- a/Zframework/sfx.lua +++ b/Zframework/sfx.lua @@ -18,7 +18,7 @@ function SFX.init(list) if love.filesystem.getInfo(fullPath)then Sources[list[i]]={love.audio.newSource(fullPath,'static')} else - MES.new('warn',"[no SFX] "..list[i]..'.ogg',.1) + LOG("No SFX: "..list[i]..'.ogg',.1) end end diff --git a/Zframework/voice.lua b/Zframework/voice.lua index e05d3c05..1e59b9af 100644 --- a/Zframework/voice.lua +++ b/Zframework/voice.lua @@ -45,8 +45,9 @@ function VOC.init(list) repeat n=n+1 until not _loadVoiceFile(path,list[i],list[i]..'_'..n) if n==1 then - _loadVoiceFile(path,list[i],list[i]) - -- if not _loadVoiceFile(path,list[i],list[i])then MES.new('warn',"[]no VOC] "..list[i],.1)end + if not _loadVoiceFile(path,list[i],list[i])then + LOG("No VOC: "..list[i],.1) + end end if not Source[list[i]][1]then Source[list[i]]=nil diff --git a/parts/scenes/app_console.lua b/parts/scenes/app_console.lua index a71299f4..9803fbc8 100644 --- a/parts/scenes/app_console.lua +++ b/parts/scenes/app_console.lua @@ -341,6 +341,20 @@ local commands={}do "Usage: mes ", }, } + commands.log={ + code=function() + local l=LOG.logs + for i=1,#l do + log(l[i]) + end + end, + description="Show the logs", + details={ + "Show the logs", + "", + "Usage: log", + }, + } commands.openurl={ code=function(url) if url~=""then