Skip to content

Commit

Permalink
fmod模块不再一直提示缺失的音乐/音效,每种名称的只提示一次
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed Jul 28, 2024
1 parent 5bc4f0c commit 9d8fc05
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions assets/fmod20221/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ M.banks={}
-- M.C2=ffi.load(fmodstudioPath)

do -- Load library
local suc,res
local suc
suc,M.C=pcall(ffi.load,'fmod')
if not suc then
MSG.new('error',"Loading FMOD lib:"..M.C)
Expand Down Expand Up @@ -175,6 +175,8 @@ function M.music.getDesc(name)
return musicLib[name]
end

local unhintedBGM={}

---@param name string
---@param args? {instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table}
---@return FMOD.Studio.EventInstance?
Expand All @@ -183,7 +185,10 @@ function M.music.play(name,args)
FMOD.music.stop()
local desc=musicLib[name]
if not desc then
MSG.new('warn',"No BGM named "..name)
if not unhintedBGM[name] then
unhintedBGM[name]=true
MSG.new('warn',"No BGM named "..name)
end
return
end
local event,res=desc:createInstance()
Expand Down Expand Up @@ -308,6 +313,8 @@ function M.effect.getDesc(name)
return effectLib[name]
end

local unhintedSFX={}

---priority: pitch>tune>fine
---
---pos:{x,y,z}
Expand All @@ -320,7 +327,10 @@ function M.effect.play(name,args)
if not studio then return end
local desc=effectLib[name]
if not desc then
MSG.new('warn',"No SE named "..name)
if not unhintedSFX[name] then
unhintedSFX[name]=true
MSG.new('warn',"No SE named "..name)
end
return
end
local event,res=desc:createInstance()
Expand Down

0 comments on commit 9d8fc05

Please sign in to comment.