Merge pull request #4 from cnelsonsic/add_spawn_func

Add a function to control spawning.
master
PilzAdam 2013-06-08 10:59:57 -07:00
commit 5596cad194
1 changed files with 4 additions and 1 deletions

View File

@ -476,7 +476,7 @@ function mobs:register_mob(name, def)
end
mobs.spawning_mobs = {}
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height)
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height, spawn_func)
mobs.spawning_mobs[name] = true
minetest.register_abm({
nodenames = nodes,
@ -510,6 +510,9 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o
if minetest.env:get_node(pos).name ~= "air" then
return
end
if spawn_func and not spawn_func(pos, node) then
return
end
if minetest.setting_getbool("display_mob_spawn") then
minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos))