diff --git a/api.lua b/api.lua index 692e172..d3d8176 100644 --- a/api.lua +++ b/api.lua @@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi") mobs = { mod = "redo", - version = "20200306", + version = "20200312", intllib = S, invis = minetest.global_exists("invisibility") and invisibility or {} } @@ -234,9 +234,11 @@ function mob_class:set_velocity(v) v = v or 0 -- set velocity with hard limit of 10 + local vel = self.object:get_velocity() + self.object:set_velocity({ x = max(-10, min((sin(yaw) * -v) + c_x, 10)), - y = max(-10, min((self.object:get_velocity().y or 0), 10)), + y = max(-10, min((vel and vel.y or 0), 10)), z = max(-10, min((cos(yaw) * v) + c_y, 10)) }) end @@ -838,6 +840,11 @@ function mob_class:is_at_cliff() return false end + -- if object no longer exists then return + if not self.object:get_luaentity() then + return false + end + local yaw = self.object:get_yaw() local dir_x = -sin(yaw) * (self.collisionbox[4] + 0.5) local dir_z = cos(yaw) * (self.collisionbox[4] + 0.5)