From af8e2093bed526439f6bc028bd324e2a28a108d2 Mon Sep 17 00:00:00 2001 From: KaadmY Date: Fri, 12 May 2017 09:30:42 -0700 Subject: [PATCH] Add object:getyaw() nan shim, should fix a common crash --- mods/mobs/api.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mods/mobs/api.lua b/mods/mobs/api.lua index 2672036..653f958 100644 --- a/mods/mobs/api.lua +++ b/mods/mobs/api.lua @@ -154,9 +154,19 @@ function mobs:register_mob(name, def) and def.drawtype == "side" then self.rotate = math.rad(90) end - local yaw = self.object:getyaw() + self.rotate + + local tmpyaw = self.object:getyaw() + local yaw = self.rotate + + if tmpyaw ~= tmpyaw then -- It's a nan value + minetest.log("warning", "[mod:mobs] object:getyaw() nan shim used") + else + yaw = yaw + tmpyaw + end + local x = math.sin(yaw) * -v local z = math.cos(yaw) * v + self.object:setvelocity({x = x, y = self.object:getvelocity().y, z = z}) end, get_velocity = function(self)