mirror of
https://github.com/Poikilos/mobs.git
synced 2023-10-03 07:28:50 -07:00
Configuration of which monsters spawn has been added.
This commit is contained in:
parent
0fad914f73
commit
40f574bea5
86
api.lua
86
api.lua
@ -470,49 +470,51 @@ end
|
|||||||
|
|
||||||
mobs.spawning_mobs = {}
|
mobs.spawning_mobs = {}
|
||||||
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height, spawn_func)
|
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height, spawn_func)
|
||||||
mobs.spawning_mobs[name] = true
|
if minetest.setting_getbool(string.gsub(name,":","_").."_spawn") ~= false then
|
||||||
minetest.register_abm({
|
mobs.spawning_mobs[name] = true
|
||||||
nodenames = nodes,
|
minetest.register_abm({
|
||||||
neighbors = {"air"},
|
nodenames = nodes,
|
||||||
interval = 30,
|
neighbors = {"air"},
|
||||||
chance = chance,
|
interval = 30,
|
||||||
action = function(pos, node, _, active_object_count_wider)
|
chance = chance,
|
||||||
if active_object_count_wider > active_object_count then
|
action = function(pos, node, _, active_object_count_wider)
|
||||||
return
|
if active_object_count_wider > active_object_count then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not mobs.spawning_mobs[name] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
pos.y = pos.y+1
|
||||||
|
if not minetest.env:get_node_light(pos) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if minetest.env:get_node_light(pos) > max_light then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if minetest.env:get_node_light(pos) < min_light then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if pos.y > max_height then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if minetest.env:get_node(pos).name ~= "air" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
pos.y = pos.y+1
|
||||||
|
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))
|
||||||
|
end
|
||||||
|
minetest.env:add_entity(pos, name)
|
||||||
end
|
end
|
||||||
if not mobs.spawning_mobs[name] then
|
})
|
||||||
return
|
end
|
||||||
end
|
|
||||||
pos.y = pos.y+1
|
|
||||||
if not minetest.env:get_node_light(pos) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if minetest.env:get_node_light(pos) > max_light then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if minetest.env:get_node_light(pos) < min_light then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if pos.y > max_height then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if minetest.env:get_node(pos).name ~= "air" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
pos.y = pos.y+1
|
|
||||||
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))
|
|
||||||
end
|
|
||||||
minetest.env:add_entity(pos, name)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function mobs:register_arrow(name, def)
|
function mobs:register_arrow(name, def)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user