From 51e244fe35d7948d6ae5c214b723e1062687057c Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 13 Sep 2022 13:23:29 +0200 Subject: [PATCH] Make logging of mob spawning configurable --- mods/ENTITIES/mcl_mobs/api.lua | 9 +++++++-- mods/ENTITIES/mcl_mobs/spawning.lua | 14 ++++++++++---- settingtypes.txt | 3 +++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 9fa48b718b..d899a02acf 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -51,6 +51,7 @@ local show_health = false -- Shows helpful debug info above each mob local mobs_debug = minetest.settings:get_bool("mobs_debug", false) +local spawn_logging = minetest.settings:get_bool("mcl_logging_mobs_spawn",true) -- Peaceful mode message so players will know there are no monsters if minetest.settings:get_bool("only_peaceful_mobs", false) then @@ -3404,7 +3405,9 @@ local mob_staticdata = function(self) and self.remove_ok and ((not self.nametag) or (self.nametag == "")) and self.lifetimer <= 20 then - minetest.log("action", "Mob "..tostring(self.name).." despawns in mob_staticdata at "..minetest.pos_to_string(self.object:get_pos())) + if spawn_logging then + minetest.log("action", "[mcl_mobs] Mob "..tostring(self.name).." despawns in mob_staticdata at "..minetest.pos_to_string(self.object:get_pos())) + end mcl_burning.extinguish(self.object) self.object:remove() @@ -3833,7 +3836,9 @@ local mob_step = function(self, dtime) and self.state ~= "attack" and self.following == nil then if self.despawn_immediately or self.lifetimer <= 0 then - minetest.log("action", "Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos, 1)) + if spawn_logging then + minetest.log("action", "[mcl_mobs] Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos, 1)) + end mcl_burning.extinguish(self.object) self.object:remove() return diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 8a48aebf99..810f9df4fb 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -39,6 +39,7 @@ local mob_cap = { --do mobs spawn? local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false local spawn_protected = minetest.settings:get_bool("mobs_spawn_protected") ~= false +local logging = minetest.settings:get_bool("mcl_logging_mobs_spawn",true) local noise_params = { offset = 0, @@ -456,8 +457,8 @@ local function spawn_check(pos,spawn_def) and (spawn_def.check_position and spawn_def.check_position(pos) or true) and (not is_farm_animal(spawn_def.name) or is_grass) and (spawn_def.type_of_spawning ~= "water" or is_water) - and not spawn_protected or not minetest.is_protected(s, "") - and not is_bedrock + and ( not spawn_protected or not minetest.is_protected(s, "") ) + and not is_bedrock then --only need to poll for node light if everything else worked local gotten_light = get_node_light(pos) if gotten_light >= spawn_def.min_light and gotten_light <= spawn_def.max_light then @@ -562,11 +563,16 @@ if mobs_spawn then --everything is correct, spawn mob local object if spawn_in_group and ( mob_type ~= "monster" or math.random(5) == 1 ) then + if logging then + minetest.log("action", "[mcl_mobs] A group of mob " .. mob_def.name .. " spawns at " .. minetest.pos_to_string(spawning_position, 1)) + end object = spawn_group(spawning_position,mob_def,{minetest.get_node(vector.offset(spawning_position,0,-1,0)).name},spawn_in_group,spawn_in_group_min) - minetest.log("action", "A group of mob " .. mob_def.name .. " spawns at " .. minetest.pos_to_string(spawning_position, 1)) + else + if logging then + minetest.log("action", "[mcl_mobs] Mob " .. mob_def.name .. " spawns at " .. minetest.pos_to_string(spawning_position, 1)) + end object = mcl_mobs.spawn(spawning_position, mob_def.name) - minetest.log("action", "Mob " .. mob_def.name .. " spawns at " .. minetest.pos_to_string(spawning_position, 1)) end diff --git a/settingtypes.txt b/settingtypes.txt index 577e4491db..5f80766538 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -182,3 +182,6 @@ mcl_enable_fapples (Enable swiftness on enchanted golden apples) bool true [Debugging] # If enabled, this will show the itemstring of an item in the description. mcl_item_id_debug (Item ID Debug) bool false + +#Log mob spawning and despawning events +mcl_logging_mobs_spawn (Log Mob Spawning) bool true