Add a function to control spawning.
This commit is contained in:
parent
b254ecd9fc
commit
ecefb2534b
5
api.lua
5
api.lua
@ -476,7 +476,7 @@ function mobs:register_mob(name, def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
mobs.spawning_mobs = {}
|
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
|
mobs.spawning_mobs[name] = true
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = nodes,
|
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
|
if minetest.env:get_node(pos).name ~= "air" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if spawn_func and not spawn_func(pos, node) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if minetest.setting_getbool("display_mob_spawn") then
|
if minetest.setting_getbool("display_mob_spawn") then
|
||||||
minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos))
|
minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user