Add new params to the spawning code
parent
c00426fcf3
commit
09f86b4ac0
|
@ -63,13 +63,16 @@ This mod add some functions that you can use in other mods:
|
||||||
-armor
|
-armor
|
||||||
and it also has the field
|
and it also has the field
|
||||||
-on_rightclick: its same as in minetest.register_entity()
|
-on_rightclick: its same as in minetest.register_entity()
|
||||||
3. mobs:register_spawn(name, nodes, max_light, min_light)
|
3. mobs:register_spawn(name, nodes, max_light, min_light, chance, mobs_per_30_block_radius)
|
||||||
This function adds the spawning of an animal (without it the
|
This function adds the spawning of an animal (without it the
|
||||||
registered animals and monster won't spawn!)
|
registered animals and monster won't spawn!)
|
||||||
"name" is the name of the animal/monster
|
"name" is the name of the animal/monster
|
||||||
"nodes" is a list of nodenames on that the animal/monster can spawn
|
"nodes" is a list of nodenames on that the animal/monster can spawn
|
||||||
"max_light" is the maximum of light
|
"max_light" is the maximum of light
|
||||||
"min_light" is the minimum of light
|
"min_light" is the minimum of light
|
||||||
|
"chance" is same as in register_abm()
|
||||||
|
"mobs_per_30_block_radius" is the maximum number of mobs in a 30 block
|
||||||
|
radius arround the possible spawning pos
|
||||||
|
|
||||||
License:
|
License:
|
||||||
Sourcecode: WTFPL (see below)
|
Sourcecode: WTFPL (see below)
|
||||||
|
|
18
init.lua
18
init.lua
|
@ -352,12 +352,12 @@ function mobs:register_animal(name, def)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function mobs:register_spawn(name, nodes, max_light, min_light)
|
function mobs:register_spawn(name, nodes, max_light, min_light, chance, mobs_per_30_block_radius)
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = nodes,
|
nodenames = nodes,
|
||||||
neighbors = nodes,
|
neighbors = nodes,
|
||||||
interval = 30,
|
interval = 30,
|
||||||
chance = 5000,
|
chance = chance,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
if not minetest.env:get_node_light(pos) then
|
if not minetest.env:get_node_light(pos) then
|
||||||
|
@ -385,7 +385,7 @@ function mobs:register_spawn(name, nodes, max_light, min_light)
|
||||||
count = count+1
|
count = count+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if count > 5 then
|
if count > mobs_per_30_block_radius then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ mobs:register_monster("mobs:dirt_monster", {
|
||||||
armor = 3,
|
armor = 3,
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1)
|
mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1, 5000, 5)
|
||||||
|
|
||||||
mobs:register_monster("mobs:stone_monster", {
|
mobs:register_monster("mobs:stone_monster", {
|
||||||
hp_max = 10,
|
hp_max = 10,
|
||||||
|
@ -432,7 +432,7 @@ mobs:register_monster("mobs:stone_monster", {
|
||||||
armor = 2,
|
armor = 2,
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:stone_monster", {"default:stone"}, 3, -1)
|
mobs:register_spawn("mobs:stone_monster", {"default:stone"}, 3, -1, 5000, 5)
|
||||||
|
|
||||||
|
|
||||||
mobs:register_monster("mobs:sand_monster", {
|
mobs:register_monster("mobs:sand_monster", {
|
||||||
|
@ -452,7 +452,7 @@ mobs:register_monster("mobs:sand_monster", {
|
||||||
armor = 3,
|
armor = 3,
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:sand_monster", {"default:desert_sand"}, 20, -1)
|
mobs:register_spawn("mobs:sand_monster", {"default:desert_sand"}, 20, -1, 5000, 5)
|
||||||
|
|
||||||
mobs:register_animal("mobs:sheep", {
|
mobs:register_animal("mobs:sheep", {
|
||||||
hp_max = 5,
|
hp_max = 5,
|
||||||
|
@ -479,7 +479,7 @@ mobs:register_animal("mobs:sheep", {
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8)
|
mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8, 5000, 3)
|
||||||
|
|
||||||
minetest.register_craftitem("mobs:meat_raw", {
|
minetest.register_craftitem("mobs:meat_raw", {
|
||||||
description = "Raw Meat",
|
description = "Raw Meat",
|
||||||
|
@ -518,7 +518,7 @@ mobs:register_animal("mobs:rat", {
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:rat", {"default:dirt_with_grass", "default:stone"}, 20, -1)
|
mobs:register_spawn("mobs:rat", {"default:dirt_with_grass", "default:stone"}, 20, -1, 5000, 1)
|
||||||
|
|
||||||
minetest.register_craftitem("mobs:rat", {
|
minetest.register_craftitem("mobs:rat", {
|
||||||
description = "Rat",
|
description = "Rat",
|
||||||
|
@ -564,4 +564,4 @@ mobs:register_monster("mobs:oerkki", {
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
light_resistant = true,
|
light_resistant = true,
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:oerkki", {"default:stone"}, 2, -1)
|
mobs:register_spawn("mobs:oerkki", {"default:stone"}, 2, -1, 5000, 5)
|
||||||
|
|
Loading…
Reference in New Issue