Skip to content
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