diff --git a/README.md b/README.md index ad0c40f..7204ecf 100644 --- a/README.md +++ b/README.md @@ -20,28 +20,32 @@ An explosive nuisance for [Minetest](http://minetest.net/). Settings: - ***sneeker.spawn_chance*** - Sets possibility for spawn. - - type: int - - default: 10000 + - type: int + - default: 10000 - ***sneeker.spawn_interval*** - Sets frequency of spawn chance. - - type: int - - default: 240 (4 minutes) + - type: int + - default: 240 (4 minutes) - ***sneeker.spawn_minlight*** - Sets the minimum light that a node must have for spawn to occur. - - type: int - - default: 0 + - type: int + - default: 0 - ***sneeker.spawn_maxlight*** - Sets the maximum light that a node can have for spawn to occur. - - type: int - - default: 9 + - type: int + - default: 9 - ***sneeker.spawn_minheight*** - Sets the maximum light that a node can have for spawn to occur. - - type: int - - default: -31000 + - type: int + - default: -31000 - ***sneeker.spawn_maxheight*** - Sets the lowest position at which sneeker can spawn. - - type: int - - default 31000 + - type: int + - default 31000 +- ***sneeker.spawn_mapblock_limit*** + - Limits the number of entities that can spawn per mapblock (16x16x16). + - type: int + - default: 1 --- ### Links: diff --git a/settings.lua b/settings.lua index 6cab9f0..87ba5e3 100644 --- a/settings.lua +++ b/settings.lua @@ -44,3 +44,8 @@ sneeker.spawn_minheight = tonumber(core.settings:get("sneeker.spawn_minheight") -- -- @setting sneeker.spawn_maxheight sneeker.spawn_maxheight = tonumber(core.settings:get("sneeker.spawn_maxheight") or 31000) + +--- Limits the number of entities that can spawn per mapblock (16x16x16). +-- +-- Default: 1 +sneeker.spawn_mapblock_limit = tonumber(core.settings:get("sneeker.spawn_mapblock_limit") or 1) diff --git a/settingtypes.txt b/settingtypes.txt index 516dc70..113397b 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -21,3 +21,6 @@ sneeker.spawn_minheight (Sneeker min spawn height) int -31000 # Sets the highest position at which sneeker can spawn. sneeker.spawn_maxheight (Sneeker max spawn height) int 31000 + +# Limits the number of entities that can spawn per mapblock (16x16x16). +sneeker.spawn_mapblock_limit (Sneeker spawn limit) int 1 diff --git a/spawn.lua b/spawn.lua index 0183724..5f1dc01 100644 --- a/spawn.lua +++ b/spawn.lua @@ -22,15 +22,13 @@ core.register_abm({ neighbors = {"air"}, interval = sneeker.spawn_interval, chance = sneeker.spawn_chance, - action = function(pos, node, _, active_object_count_wider) - if active_object_count_wider > 5 then - return - end + action = function(pos, node, aoc, aocw) + if aoc >= sneeker.spawn_mapblock_limit then return end - if pos.y > sneeker.spawn_maxheight then - return - end - if pos.y < sneeker.spawn_minheight then + -- check above target node + pos.y = pos.y+1 + + if pos.y > sneeker.spawn_maxheight or pos.y < sneeker.spawn_minheight then return end