添加log模块,用于代替之前缺少音频文件弹出的消息框
也给缺少图片和加载错误语言等地方添加了日志 控制台添加log命令输出日志
This commit is contained in:
@@ -62,16 +62,20 @@ function BGM.init(list)
|
|||||||
Sources[name]:setLooping(true)
|
Sources[name]:setLooping(true)
|
||||||
Sources[name]:setVolume(0)
|
Sources[name]:setVolume(0)
|
||||||
return true
|
return true
|
||||||
-- else
|
else
|
||||||
-- MES.new('warn',"[no BGM] "..Sources[name],5)
|
LOG("No BGM: "..Sources[name],5)
|
||||||
end
|
end
|
||||||
elseif Sources[name]then
|
elseif Sources[name]then
|
||||||
return true
|
return true
|
||||||
-- elseif name then
|
elseif name then
|
||||||
-- MES.new('warn',"No BGM: "..name,5)
|
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
|
||||||
end
|
end
|
||||||
function BGM.loadAll()for name in next,Sources do _load(name)end end
|
|
||||||
function BGM.play(name)
|
function BGM.play(name)
|
||||||
name=name or BGM.default
|
name=name or BGM.default
|
||||||
if not _load(name)then return end
|
if not _load(name)then return end
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function IMG.init(list)
|
|||||||
elseif type(list[name])=='string'then
|
elseif type(list[name])=='string'then
|
||||||
self[name]=love.graphics.newImage(list[name])
|
self[name]=love.graphics.newImage(list[name])
|
||||||
else
|
else
|
||||||
MES.new('warn',"No IMG: "..name,5)
|
LOG("No IMG: "..name)
|
||||||
self[name]=null
|
self[name]=null
|
||||||
end
|
end
|
||||||
return self[name]
|
return self[name]
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ do--Add pcall & MES for JSON lib
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Pure lua modules (complex)
|
--Pure lua modules (complex)
|
||||||
|
LOG= require'Zframework.log'
|
||||||
REQUIRE= require'Zframework.require'
|
REQUIRE= require'Zframework.require'
|
||||||
TASK= require'Zframework.task'
|
TASK= require'Zframework.task'
|
||||||
WS= require'Zframework.websocket'
|
WS= require'Zframework.websocket'
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ function LANG.init(defaultLang,langList,publicText,pretreatFunc)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function LANG.get(l)
|
function LANG.get(l)
|
||||||
|
if not langList[l]then
|
||||||
|
LOG("Wrong language: "..tostring(l))
|
||||||
|
l=defaultLang
|
||||||
|
end
|
||||||
return langList[l]
|
return langList[l]
|
||||||
end
|
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
|
if love.filesystem.getInfo(fullPath)then
|
||||||
Sources[list[i]]={love.audio.newSource(fullPath,'static')}
|
Sources[list[i]]={love.audio.newSource(fullPath,'static')}
|
||||||
else
|
else
|
||||||
MES.new('warn',"[no SFX] "..list[i]..'.ogg',.1)
|
LOG("No SFX: "..list[i]..'.ogg',.1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ function VOC.init(list)
|
|||||||
repeat n=n+1 until not _loadVoiceFile(path,list[i],list[i]..'_'..n)
|
repeat n=n+1 until not _loadVoiceFile(path,list[i],list[i]..'_'..n)
|
||||||
|
|
||||||
if n==1 then
|
if n==1 then
|
||||||
_loadVoiceFile(path,list[i],list[i])
|
if not _loadVoiceFile(path,list[i],list[i])then
|
||||||
-- if not _loadVoiceFile(path,list[i],list[i])then MES.new('warn',"[]no VOC] "..list[i],.1)end
|
LOG("No VOC: "..list[i],.1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if not Source[list[i]][1]then
|
if not Source[list[i]][1]then
|
||||||
Source[list[i]]=nil
|
Source[list[i]]=nil
|
||||||
|
|||||||
@@ -341,6 +341,20 @@ local commands={}do
|
|||||||
"Usage: mes <check|info|warn|error>",
|
"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={
|
commands.openurl={
|
||||||
code=function(url)
|
code=function(url)
|
||||||
if url~=""then
|
if url~=""then
|
||||||
|
|||||||
Reference in New Issue
Block a user