diff --git a/README.txt b/README.txt index d56baf2..2d3dc3d 100644 --- a/README.txt +++ b/README.txt @@ -63,13 +63,16 @@ This mod add some functions that you can use in other mods: -armor and it also has the field -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 registered animals and monster won't spawn!) "name" is the name of the animal/monster "nodes" is a list of nodenames on that the animal/monster can spawn "max_light" is the maximum 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: Sourcecode: WTFPL (see below) diff --git a/init.lua b/init.lua index ca4c083..7cec741 100644 --- a/init.lua +++ b/init.lua @@ -352,12 +352,12 @@ function mobs:register_animal(name, def) }) 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({ nodenames = nodes, neighbors = nodes, interval = 30, - chance = 5000, + chance = chance, action = function(pos, node) pos.y = pos.y+1 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 end end - if count > 5 then + if count > mobs_per_30_block_radius then return end @@ -413,7 +413,7 @@ mobs:register_monster("mobs:dirt_monster", { armor = 3, 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", { hp_max = 10, @@ -432,7 +432,7 @@ mobs:register_monster("mobs:stone_monster", { armor = 2, 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", { @@ -452,7 +452,7 @@ mobs:register_monster("mobs:sand_monster", { armor = 3, 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", { hp_max = 5, @@ -479,7 +479,7 @@ mobs:register_animal("mobs:sheep", { 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", { description = "Raw Meat", @@ -518,7 +518,7 @@ mobs:register_animal("mobs:rat", { 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", { description = "Rat", @@ -564,4 +564,4 @@ mobs:register_monster("mobs:oerkki", { drawtype = "front", light_resistant = true, }) -mobs:register_spawn("mobs:oerkki", {"default:stone"}, 2, -1) +mobs:register_spawn("mobs:oerkki", {"default:stone"}, 2, -1, 5000, 5)