Use unique name for function. Add development flag to enable crashing locally

This commit is contained in:
ancientmarinerdev 2023-03-07 19:49:25 +00:00 committed by Gitea
parent b47ef9275b
commit 5fc78bf6b0
2 changed files with 14 additions and 5 deletions

View File

@ -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

View File

@ -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"