diff --git a/spawners_env/spawners_gen.lua b/spawners_env/spawners_gen.lua index 4f91f0f..46f6d01 100644 --- a/spawners_env/spawners_gen.lua +++ b/spawners_env/spawners_gen.lua @@ -43,14 +43,20 @@ local function place_spawner(param) pos.y = pos.y + 1 end - local spawner_name = spawners_env.registered_spawners_names[math.random(1, #spawners_mobs.registered_spawners_names)] + local spawner_name - if gen_obj == 'dungeon' then - minetest.set_node(pos, { name = spawner_name }) - minetest.log('action', '[Spawners] dungeon spawner ' .. spawner_name .. ' placed at: ' .. minetest.pos_to_string(pos)) - else - minetest.set_node(pos, { name = spawner_name }) - minetest.log('action', '[Spawners] temple spawner ' .. spawner_name .. ' placed at: ' .. minetest.pos_to_string(pos)) + if #spawners_env.registered_spawners_names > 0 then + spawner_name = spawners_env.registered_spawners_names[math.random(1, #spawners_env.registered_spawners_names)] + end + + if spawner_name then + if gen_obj == 'dungeon' then + minetest.set_node(pos, { name = spawner_name }) + minetest.log('action', '[Spawners] dungeon spawner ' .. spawner_name .. ' placed at: ' .. minetest.pos_to_string(pos)) + else + minetest.set_node(pos, { name = spawner_name }) + minetest.log('action', '[Spawners] temple spawner ' .. spawner_name .. ' placed at: ' .. minetest.pos_to_string(pos)) + end end end end