Fix type and add some nil checks

This commit is contained in:
Juraj Vajda 2023-04-26 17:11:50 -04:00
parent 503c718a7a
commit 15466f92f3

View File

@ -43,8 +43,13 @@ local function place_spawner(param)
pos.y = pos.y + 1 pos.y = pos.y + 1
end end
local spawner_name = spawners_env.registered_spawners_names[math.random(1, #spawners_mobs.registered_spawners_names)] local spawner_name
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 if gen_obj == 'dungeon' then
minetest.set_node(pos, { name = spawner_name }) minetest.set_node(pos, { name = spawner_name })
minetest.log('action', '[Spawners] dungeon spawner ' .. spawner_name .. ' placed at: ' .. minetest.pos_to_string(pos)) minetest.log('action', '[Spawners] dungeon spawner ' .. spawner_name .. ' placed at: ' .. minetest.pos_to_string(pos))
@ -54,6 +59,7 @@ local function place_spawner(param)
end end
end end
end end
end
minetest.set_gen_notify('dungeon') minetest.set_gen_notify('dungeon')
minetest.set_gen_notify('temple') minetest.set_gen_notify('temple')