Tweak spawning
This commit is contained in:
parent
843009965f
commit
886434b79b
19
api.lua
19
api.lua
@ -334,14 +334,17 @@ function mobs:register_mob(name, def)
|
||||
end
|
||||
|
||||
mobs.spawning_mobs = {}
|
||||
function mobs:register_spawn(name, nodes, max_light, min_light, chance, mobs_per_30_block_radius, max_height)
|
||||
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height)
|
||||
mobs.spawning_mobs[name] = true
|
||||
minetest.register_abm({
|
||||
nodenames = nodes,
|
||||
neighbors = nodes,
|
||||
interval = 30,
|
||||
chance = chance,
|
||||
action = function(pos, node)
|
||||
action = function(pos, node, _, active_object_count_wider)
|
||||
if active_object_count_wider > active_object_count then
|
||||
return
|
||||
end
|
||||
if not mobs.spawning_mobs[name] then
|
||||
return
|
||||
end
|
||||
@ -366,18 +369,6 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, mobs_per
|
||||
return
|
||||
end
|
||||
|
||||
local count = 0
|
||||
for _,obj in pairs(minetest.env:get_objects_inside_radius(pos, 30)) do
|
||||
if obj:is_player() then
|
||||
return
|
||||
elseif obj:get_luaentity() and obj:get_luaentity().name == name then
|
||||
count = count+1
|
||||
end
|
||||
end
|
||||
if count > mobs_per_30_block_radius 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
|
||||
|
4
init.lua
4
init.lua
@ -122,7 +122,7 @@ mobs:register_mob("mobs:sheep", {
|
||||
end
|
||||
end,
|
||||
})
|
||||
mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8, 9000, 0, 31000)
|
||||
mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8, 9000, 1, 31000)
|
||||
|
||||
minetest.register_craftitem("mobs:meat_raw", {
|
||||
description = "Raw Meat",
|
||||
@ -248,7 +248,7 @@ mobs:register_mob("mobs:dungeon_master", {
|
||||
attack = "mobs_fireball",
|
||||
},
|
||||
})
|
||||
mobs:register_spawn("mobs:dungeon_master", {"default:stone"}, 2, -1, 7000, 0, -50)
|
||||
mobs:register_spawn("mobs:dungeon_master", {"default:stone"}, 2, -1, 7000, 1, -50)
|
||||
|
||||
mobs:register_arrow("mobs:fireball", {
|
||||
visual = "sprite",
|
||||
|
Loading…
x
Reference in New Issue
Block a user