mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-26 03:07:32 +01:00
Adding error handling to the mob step function
This commit is contained in:
parent
db7f4699eb
commit
ae92c51155
@ -357,8 +357,7 @@ function mob_class:outside_limits()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- main mob function
|
local function on_step_work (self, dtime)
|
||||||
function mob_class:on_step(dtime)
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
if not pos then return end
|
if not pos then return end
|
||||||
|
|
||||||
@ -446,6 +445,31 @@ function mob_class:on_step(dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local on_step_error_handler = function ()
|
||||||
|
--lua_Debug ar;
|
||||||
|
--local L = lua_getfield(L, LUA_GLOBALSINDEX, "f");
|
||||||
|
--lua_getinfo(L, ">S", &ar);
|
||||||
|
local info = debug.getinfo(1, "SnlufL")
|
||||||
|
|
||||||
|
minetest.log("In the error handler")
|
||||||
|
minetest.log("debug.traceback: ".. tostring(debug.traceback()))
|
||||||
|
minetest.log("debug.short_src: ".. dump(debug.source))
|
||||||
|
minetest.log("debug.short_src: ".. dump(info))
|
||||||
|
--debug.traceback
|
||||||
|
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
|
||||||
|
--minetest.log("success. retVal: ".. tostring(retVal))
|
||||||
|
return retVal
|
||||||
|
else
|
||||||
|
minetest.log("failed. error: ".. tostring(retVal))
|
||||||
|
minetest.log("failed. status: ".. tostring(status))
|
||||||
|
end
|
||||||
|
--return on_step_work(self, dtime)
|
||||||
|
end
|
||||||
|
|
||||||
local timer = 0
|
local timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
timer = timer + dtime
|
timer = timer + dtime
|
||||||
|
Loading…
Reference in New Issue
Block a user