mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 22:13:27 +02:00
Fix Lua errors when the client is built without the sound framework (#1142)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
local musicFilename = "/sounds/startup"
|
||||
local musicChannel = g_sounds.getChannel(1)
|
||||
local musicChannel = nil
|
||||
if g_sounds then
|
||||
musicChannel = g_sounds.getChannel(SoundChannels.Music)
|
||||
end
|
||||
|
||||
function setMusic(filename)
|
||||
musicFilename = filename
|
||||
@@ -27,12 +30,14 @@ end
|
||||
|
||||
function startup()
|
||||
-- Play startup music (The Silver Tree, by Mattias Westlund)
|
||||
musicChannel:enqueue(musicFilename, 3)
|
||||
connect(g_game, { onGameStart = function() musicChannel:stop(3) end })
|
||||
connect(g_game, { onGameEnd = function()
|
||||
g_sounds.stopAll()
|
||||
musicChannel:enqueue(musicFilename, 3)
|
||||
end })
|
||||
if musicChannel then
|
||||
musicChannel:enqueue(musicFilename, 3)
|
||||
connect(g_game, { onGameStart = function() musicChannel:stop(3) end })
|
||||
connect(g_game, { onGameEnd = function()
|
||||
g_sounds.stopAll()
|
||||
musicChannel:enqueue(musicFilename, 3)
|
||||
end })
|
||||
end
|
||||
|
||||
-- Check for startup errors
|
||||
local errtitle = nil
|
||||
@@ -57,7 +62,9 @@ function init()
|
||||
onExit = exit })
|
||||
|
||||
g_window.setMinimumSize({ width = 600, height = 480 })
|
||||
g_sounds.preload(musicFilename)
|
||||
if musicChannel then
|
||||
g_sounds.preload(musicFilename)
|
||||
end
|
||||
|
||||
-- initialize in fullscreen mode on mobile devices
|
||||
if g_window.getPlatformType() == "X11-EGL" then
|
||||
|
Reference in New Issue
Block a user