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,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