From 39a0353a493866b56818aa30dec61dc33bd1223e Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 7 Oct 2022 22:46:13 +0200 Subject: [PATCH] Add spawn counts per mob to /mobstats --- mods/ENTITIES/mcl_mobs/spawning.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 64ac6786d..afa4c4ad2 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -25,6 +25,7 @@ local table_remove = table.remove local pairs = pairs local dbg_spawn_attempts = 0 local dbg_spawn_succ = 0 +local dbg_spawn_counts = {} -- range for mob count local aoc_range = 136 @@ -473,6 +474,11 @@ function mcl_mobs.spawn(pos,id) if not def or (def.can_spawn and not def.can_spawn(pos)) or not def.is_mob then return false end + if not dbg_spawn_counts[def.name] then + dbg_spawn_counts[def.name] = 1 + else + dbg_spawn_counts[def.name] = dbg_spawn_counts[def.name] + 1 + end return minetest.add_entity(pos, def.name) end @@ -672,6 +678,7 @@ end minetest.register_chatcommand("mobstats",{ privs = { debug = true }, func = function(n,param) + minetest.chat_send_player(n,dump(dbg_spawn_counts)) local pos = minetest.get_player_by_name(n):get_pos() minetest.chat_send_player(n,"mobs within 32 radius of player:"..count_mobs(pos,32)) minetest.chat_send_player(n,"total mobs:"..count_mobs_total())