Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix when compiled without sound support #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modules/01-afk/afk.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ function AfkModule.getPanel() return Panel end
function AfkModule.setPanel(panel) Panel = panel end

function AfkModule.init()
g_sounds.preload('alert.ogg')
if g_sounds then
g_sounds.preload('alert.ogg')
end

dofile('alertlist.lua')
AlertList.init()
Expand Down
15 changes: 10 additions & 5 deletions modules/01-afk/events/creaturealert.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
AfkModule.CreatureAlert = {}
CreatureAlert = AfkModule.CreatureAlert

local alertSoundChannel = g_sounds.getChannel(1)
local alertSoundChannel = nil
if g_sounds then
alertSoundChannel = g_sounds.getChannel(1)
end

function CreatureAlert.Event(event)
local blackList = AlertList.getBlackList()
Expand All @@ -19,15 +22,15 @@ function CreatureAlert.Event(event)
creatures = g_map.getSpectators(player:getPosition(), false)

local alert = false
if AlertList.getBlackOrWhite() then
if AlertList.getBlackOrWhite() then
-- black
for k, v in pairs (creatures) do
if v ~= player and AlertList.isBlackListed(v:getName()) then
alert = true
break
end
end
else
else
-- white
for k, v in pairs (creatures) do
if v ~= player and not AlertList.isWhiteListed(v:getName()) then
Expand All @@ -51,5 +54,7 @@ function CreatureAlert.alert()
end

function CreatureAlert.stopAlert()
alertSoundChannel:stop()
end
if alertSoundChannel then
alertSoundChannel:stop()
end
end