More spawning fixes
parent
1d39a4c6c1
commit
ca8f78cec8
12
init.lua
12
init.lua
|
@ -59,13 +59,11 @@ function creatures.spawn(pos, number, mob, limit, range, abs_max)
|
||||||
local z = 1/math.random(1,3)
|
local z = 1/math.random(1,3)
|
||||||
local p = {x=pos.x+x,y=pos.y,z=pos.z+z}
|
local p = {x=pos.x+x,y=pos.y,z=pos.z+z}
|
||||||
if mobs+i <= limit and spawned+i < abs_max then
|
if mobs+i <= limit and spawned+i < abs_max then
|
||||||
minetest.after(i/5,function()
|
local obj = minetest.add_entity(p, mob)
|
||||||
local obj = minetest.add_entity(p, mob)
|
if obj then
|
||||||
if obj then
|
creatures.spawned[m_name] = spawned + 1
|
||||||
creatures.spawned[m_name] = spawned + 1
|
minetest.log("action", "Spawned "..mob.." at ("..pos.x..","..pos.y..","..pos.z..")")
|
||||||
minetest.log("action", "Spawned "..mob.." at ("..pos.x..","..pos.y..","..pos.z..")")
|
end
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,7 @@ if not minetest.setting_getbool("only_peaceful_mobs") then
|
||||||
-- zombie
|
-- zombie
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = creatures.z_spawn_nodes,
|
nodenames = creatures.z_spawn_nodes,
|
||||||
|
neighbors = {"air"},
|
||||||
interval = 40.0,
|
interval = 40.0,
|
||||||
chance = 7600,
|
chance = 7600,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
@ -37,6 +38,7 @@ if not minetest.setting_getbool("only_peaceful_mobs") then
|
||||||
-- ghost
|
-- ghost
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = creatures.g_spawn_nodes,
|
nodenames = creatures.g_spawn_nodes,
|
||||||
|
neighbors = {"air"},
|
||||||
interval = 44.0,
|
interval = 44.0,
|
||||||
chance = 8350,
|
chance = 8350,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
@ -75,6 +77,7 @@ end
|
||||||
-- peaceful
|
-- peaceful
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = creatures.s_spawn_nodes,
|
nodenames = creatures.s_spawn_nodes,
|
||||||
|
neighbors = {"air"},
|
||||||
interval = 55.0,
|
interval = 55.0,
|
||||||
chance = 7800,
|
chance = 7800,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
@ -94,5 +97,5 @@ minetest.register_abm({
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if math.random(1,10) > 8 then return end
|
if math.random(1,10) > 8 then return end
|
||||||
creatures.spawn(pos, math.random(1,2), "creatures:sheep", 4, 50)
|
creatures.spawn(pos, math.random(1,2), "creatures:sheep", 4, 50, 30)
|
||||||
end})
|
end})
|
||||||
|
|
Loading…
Reference in New Issue