silveralol
Advanced OT User
- Joined
- Mar 16, 2010
- Messages
- 1,484
- Solutions
- 9
- Reaction score
- 217
hello, I'm trying make a script to create a random boss in some position, I need check the bosses names to not respawn again the bosses, I need make that when is in the table run the code again to try spawn another, while spawn a different boss
here the script:
of course the table "config" have more than 1 member
here the script:
Code:
local config = {
[1] = {bossName = "Name", bossPosition = Position()}
}
Bosses = {}
function onThink(interval, lastExecution, thinkInterval)
math.randomseed(os.time())
local rand = config[math.random(#config)]
local name = rand.bossName
if isInArray(Bosses, name) then
print('>> attempt to spawn '..name..' again.')
return true
end
table.insert(Bosses, name)
local monster = Game.createMonster(rand.bossName, rand.bossPosition)
if not monster then
print('>> Failed to spawn '..name..' is missing map.')
return true
end
print('>> The boss: ' ..monster:getName() .. ' spawn.')
return true
end