undead mage
Active Member
Hi, so im trying to make a boss script and im looking into other scripts how ppl have done it and I found this part but I just can't figure out what it does. Can anyone help me understand this?
Code:
local function filter(list, f, i)
if i < #list then
if f(list[i]) then
return list[i], filter(list, f, i + 1)
else
return filter(list, f, i + 1)
end
elseif list[i] and f(list[i]) then
return list[i]
end
end
Code:
local spectators = Game.getSpectators(info.center, false, false, 0, info.rangeX, 0, info.rangeY)
if not filter(spectators, function(c) return c:isMonster() end, 1) then
local boss = Game.createMonster(info.boss, info.center)
boss:registerEvent('WarzoneBossDeath')
end