mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-24 01:30:22 +01:00
add mobs:spawn_abm_check() function
This commit is contained in:
parent
763fbee36d
commit
1bb95d742c
13
api.lua
13
api.lua
@ -3,7 +3,7 @@
|
||||
|
||||
mobs = {}
|
||||
mobs.mod = "redo"
|
||||
mobs.version = "20180313"
|
||||
mobs.version = "20180322"
|
||||
|
||||
|
||||
-- Intllib
|
||||
@ -2983,6 +2983,12 @@ end
|
||||
|
||||
-- global functions
|
||||
|
||||
function mobs:spawn_abm_check(pos, node, name)
|
||||
-- global function to add additional spawn checks
|
||||
-- return true to stop spawning mob
|
||||
end
|
||||
|
||||
|
||||
function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||
interval, chance, aoc, min_height, max_height, day_toggle, on_spawn)
|
||||
|
||||
@ -3027,6 +3033,11 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||
return
|
||||
end
|
||||
|
||||
-- additional custom checks for spawning mob
|
||||
if mobs:spawn_abm_check(pos, node, name) == true then
|
||||
return
|
||||
end
|
||||
|
||||
-- do not spawn if too many of same mob in area
|
||||
if active_object_count_wider >= max_per_block
|
||||
or count_mobs(pos, name) >= aoc then
|
||||
|
11
api.txt
11
api.txt
@ -346,6 +346,17 @@ only use the API of this mod by disabling the spawning of the default mobs in
|
||||
this mod.
|
||||
|
||||
|
||||
mobs:spawn_abm_check(pos, node, name)
|
||||
|
||||
This global function can be changed to contain additional checks for mobs to
|
||||
spawn e.g. mobs that spawn only in specific areas and the like. By returning
|
||||
true the mob will not spawn.
|
||||
|
||||
'pos' holds the position of the spawning mob
|
||||
'node' contains the node the mob is spawning on top of
|
||||
'name' is the name of the animal/monster
|
||||
|
||||
|
||||
Making Arrows
|
||||
-------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user