E
Evil Puncker
Guest
Sup everyone, I'm using the amazing raid script by @Nekiro , it works like a charm and all, but it also throws an error and I tried to "fix" that but I don't know where to begin with, so here I am asking for help, follows the script:
and the error:
Lua:
local raids = {
-- Bosses
[1] = {type = "BOSS", position = Position(49, 172, 10), monster = "Demodras", message = "Demodras has spawned", chance = 3},
[2] = {type = "BOSS", position = Position(115, 88, 7), monster = "Grorlam", message = "Grorlam has spawned", chance = 2},
[3] = {type = "BOSS", position = Position(102, 41, 8), monster = "Rotworm Queen", message = "Rotworm Queen has spawned", chance = 2},
-- Raids fromPos, toPos
[4] = {type = "NORMAL", fromPos = Position(127, 35, 7), toPos = Position(184, 65, 7), monsters = {"minotaur", "minotaur guard", "minotaur mage", "minotaur archer"}, count = 50, message = "Minotaur assault incoming!", chance = 20},
[6] = {type = "NORMAL", fromPos = Position(127, 35, 7), toPos = Position(184, 65, 7), monsters = "Feverish Citizen", count = 50, message = "Feverish Citizens have invaded the streets!", chance = 10},
}
local spawnedBosses = {}
local function isSpawned(name)
for i = 1, #spawnedBosses do
local monster = Monster(spawnedBosses[i])
if monster and monster:getName():lower() == name then
return true
else
spawnedBosses[i] = nil
end
end
return false
end
local globalevent = GlobalEvent("SpawnRaid")
function globalevent.onThink(...)
local table = raids[math.random(#raids)]
if math.random(100) > table.chance then
return true
end
if table.type == "BOSS" then
if not isSpawned(table.monster:lower()) then
local boss = Game.createMonster(table.monster, table.position, true, false)
if boss then
spawnedBosses[#spawnedBosses + 1] = boss:getId()
end
if table.message ~= nil then
broadcastMessage(table.message, MESSAGE_EVENT_ADVANCE)
end
end
elseif table.type == "NORMAL" then
for i = 1, table.count do
local randomPosition = Position(math.random(table.fromPos.x, table.toPos.x), math.random(table.fromPos.y, table.toPos.y), table.fromPos.z)
if type(table.monsters) == "string" then
Game.createMonster(table.monsters, randomPosition, true, false)
else
Game.createMonster(table.monsters[math.random(#table.monsters)], randomPosition, true, false)
end
end
if table.message ~= nil then
broadcastMessage(table.message, MESSAGE_EVENT_ADVANCE)
end
end
return true
end
globalevent:interval(1800000) -- will be executed every 1000ms
globalevent:register()
and the error:
\data\scripts\globalevents\raids.lua:31: attempt to index local 'table' (a nil value)