From 5fc78bf6b044e5daace1a2837a79e0042784e3a0 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Tue, 7 Mar 2023 19:49:25 +0000 Subject: [PATCH] Use unique name for function. Add development flag to enable crashing locally --- mods/ENTITIES/mcl_mobs/api.lua | 17 +++++++++++++---- mods/ENTITIES/mcl_mobs/movement.lua | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 29ff16cf8..d3b80a66b 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -9,6 +9,8 @@ local CRASH_WARN_FREQUENCY = 60 -- Localize local S = minetest.get_translator("mcl_mobs") +local DEVELOPMENT = minetest.settings:get_bool("mcl_development",false) + local LOGGING_ON = minetest.settings:get_bool("mcl_logging_mobs_villager",false) local function mcl_log (message) if LOGGING_ON then @@ -415,7 +417,7 @@ local function on_step_work (self, dtime) self:env_danger_movement_checks (dtime) -- Follow code is heavy and probably shouldn't run when not in range, but we need to extract the cancel follow stuff - self:follow() + self:check_follow() self:flop() self:check_smooth_rotation(dtime) @@ -493,12 +495,19 @@ local on_step_error_handler = function () minetest.log("action", "--- Bug report end ---") end + + -- main mob function function mob_class:on_step(dtime) - local status, retVal = xpcall(on_step_work, on_step_error_handler, self, dtime) - if status then - return retVal + if not DEVELOPMENT then + local status, retVal = xpcall(on_step_work, on_step_error_handler, self, dtime) + if status then + return retVal + end + else + return on_step_work (self, dtime) end + end local timer = 0 diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index 39a732010..b565021c9 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -614,7 +614,7 @@ end -- follow player if owner or holding item, if fish outta water then flop -function mob_class:follow() +function mob_class:check_follow() -- find player to follow if (self.follow ~= "" or self.order == "follow") and not self.following and self.state ~= "attack"