添加log模块,用于代替之前缺少音频文件弹出的消息框
也给缺少图片和加载错误语言等地方添加了日志 控制台添加log命令输出日志
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
19
Zframework/log.lua
Normal file
19
Zframework/log.lua
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -341,6 +341,20 @@ local commands={}do
|
||||
"Usage: mes <check|info|warn|error>",
|
||||
},
|
||||
}
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user