Added MarkBu's new mob:spawn command

This commit is contained in:
TenPlus1 2016-08-03 09:34:36 +01:00
parent a470ac7cc1
commit e944712c90
2 changed files with 28 additions and 2 deletions

23
api.lua
View File

@ -1,5 +1,5 @@
-- Mobs Api (21st July 2016)
-- Mobs Api (3rd August 2016)
mobs = {}
mobs.mod = "redo"
@ -2400,7 +2400,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
chance = chance,
catch_up = true,
action = function(pos, node, aoc, active_object_count_wider)
action = function(pos, node, active_object_count, active_object_count_wider)
-- do not spawn if too many active entities in area
if active_object_count_wider > active_object_count
@ -2491,6 +2491,25 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o
chance, active_object_count, -31000, max_height, day_toggle)
end
-- MarkBu's spawn function
function mobs:spawn(def)
local name = def.name
local nodes = def.nodes or {"group:soil", "group:stone"}
local neighbors = def.neighbors or {"air"}
local min_light = def.min_light or 0
local max_light = def.max_light or 15
local interval = def.interval or 30
local chance = def.chance or 5000
local active_object_count = def.active_object_count or 1
local min_height = def.min_height or -31000
local max_height = def.max_height or 31000
local day_toggle = def.day_toggle or nil
mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, interval,
chance, active_object_count, min_height, max_height, day_toggle)
end
-- set content id's
local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")

View File

@ -152,6 +152,13 @@ These functions register a spawn algorithm for the mob. Without this function th
'max_height' is the maximum height the mob can spawn
'day_toggle' true for day spawning, false for night or nil for anytime
... also a simpler way to handle mob spawns has been added with the mobs:spawn(def) command which uses above names to make settings clearer:
mobs:spawn({name = "mobs_monster:tree_monster",
nodes = {"group:leaves"},
max_light = 7,
})
Players can override the spawn chance for each mob registered by adding a line to their minetest.conf file with a new value, the lower the value the more each mob will spawn e.g.