Add setting to chance spawn mapblock limit
This commit is contained in:
parent
94c22a5406
commit
0cb069edeb
28
README.md
28
README.md
@ -20,28 +20,32 @@ An explosive nuisance for [Minetest](http://minetest.net/).
|
|||||||
Settings:
|
Settings:
|
||||||
- ***sneeker.spawn_chance***
|
- ***sneeker.spawn_chance***
|
||||||
- Sets possibility for spawn.
|
- Sets possibility for spawn.
|
||||||
- type: int
|
- type: int
|
||||||
- default: 10000
|
- default: 10000
|
||||||
- ***sneeker.spawn_interval***
|
- ***sneeker.spawn_interval***
|
||||||
- Sets frequency of spawn chance.
|
- Sets frequency of spawn chance.
|
||||||
- type: int
|
- type: int
|
||||||
- default: 240 (4 minutes)
|
- default: 240 (4 minutes)
|
||||||
- ***sneeker.spawn_minlight***
|
- ***sneeker.spawn_minlight***
|
||||||
- Sets the minimum light that a node must have for spawn to occur.
|
- Sets the minimum light that a node must have for spawn to occur.
|
||||||
- type: int
|
- type: int
|
||||||
- default: 0
|
- default: 0
|
||||||
- ***sneeker.spawn_maxlight***
|
- ***sneeker.spawn_maxlight***
|
||||||
- Sets the maximum light that a node can have for spawn to occur.
|
- Sets the maximum light that a node can have for spawn to occur.
|
||||||
- type: int
|
- type: int
|
||||||
- default: 9
|
- default: 9
|
||||||
- ***sneeker.spawn_minheight***
|
- ***sneeker.spawn_minheight***
|
||||||
- Sets the maximum light that a node can have for spawn to occur.
|
- Sets the maximum light that a node can have for spawn to occur.
|
||||||
- type: int
|
- type: int
|
||||||
- default: -31000
|
- default: -31000
|
||||||
- ***sneeker.spawn_maxheight***
|
- ***sneeker.spawn_maxheight***
|
||||||
- Sets the lowest position at which sneeker can spawn.
|
- Sets the lowest position at which sneeker can spawn.
|
||||||
- type: int
|
- type: int
|
||||||
- default 31000
|
- default 31000
|
||||||
|
- ***sneeker.spawn_mapblock_limit***
|
||||||
|
- Limits the number of entities that can spawn per mapblock (16x16x16).
|
||||||
|
- type: int
|
||||||
|
- default: 1
|
||||||
|
|
||||||
---
|
---
|
||||||
### Links:
|
### Links:
|
||||||
|
@ -44,3 +44,8 @@ sneeker.spawn_minheight = tonumber(core.settings:get("sneeker.spawn_minheight")
|
|||||||
--
|
--
|
||||||
-- @setting sneeker.spawn_maxheight
|
-- @setting sneeker.spawn_maxheight
|
||||||
sneeker.spawn_maxheight = tonumber(core.settings:get("sneeker.spawn_maxheight") or 31000)
|
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)
|
||||||
|
@ -21,3 +21,6 @@ sneeker.spawn_minheight (Sneeker min spawn height) int -31000
|
|||||||
|
|
||||||
# Sets the highest position at which sneeker can spawn.
|
# Sets the highest position at which sneeker can spawn.
|
||||||
sneeker.spawn_maxheight (Sneeker max spawn height) int 31000
|
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
|
||||||
|
14
spawn.lua
14
spawn.lua
@ -22,15 +22,13 @@ core.register_abm({
|
|||||||
neighbors = {"air"},
|
neighbors = {"air"},
|
||||||
interval = sneeker.spawn_interval,
|
interval = sneeker.spawn_interval,
|
||||||
chance = sneeker.spawn_chance,
|
chance = sneeker.spawn_chance,
|
||||||
action = function(pos, node, _, active_object_count_wider)
|
action = function(pos, node, aoc, aocw)
|
||||||
if active_object_count_wider > 5 then
|
if aoc >= sneeker.spawn_mapblock_limit then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if pos.y > sneeker.spawn_maxheight then
|
-- check above target node
|
||||||
return
|
pos.y = pos.y+1
|
||||||
end
|
|
||||||
if pos.y < sneeker.spawn_minheight then
|
if pos.y > sneeker.spawn_maxheight or pos.y < sneeker.spawn_minheight then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user