As there doesn't seem to be a definite fork/successor to this mod yet, I am posting this issue here.
While testing, I discovered that cme is computing the yaw of mobs in a strange fashion, which will cause the value to become larger than 360, and not simply by accident (I've seen values larger than 720 !). I am working on a minetest patch (minetest/minetest#4425) to prevent values that are too far out of range from causing problems, and it will reject values larger than 720. That means that cme mobs will cause lua errors after the PR is merged.
I created the following quick-and-dirty patch which will adjust the values before setting the yaw. I suppose somebody will want to create a better patch, that ensures the computed yaw will never become too large to begin with (although my PR will accept and adjust values up to 720).
diff --git a/creatures/functions.lua b/creatures/functions.lua
index 178bbce..4eb9307 100644
--- a/creatures/functions.lua
+++ b/creatures/functions.lua
@@ -108,6 +108,7 @@ local function getYaw(dirOrYaw)
-- here could be a value based on given yaw
end
+ yaw = yaw % (2 * math.pi)
return yaw
end
@@ -549,7 +550,9 @@ creatures.on_step = function(self, dtime)
local moving_speed = modes[current_mode].moving_speed or 0
if moving_speed > 0 then
local yaw = (getYaw(me:getyaw()) + 90.0) * DEGTORAD
- me:setyaw(yaw + 4.73)
+ yaw = yaw + 4.73
+ yaw = yaw % (2 * math.pi)
+ me:setyaw(yaw)
self.dir = {x = math.cos(yaw), y = 0, z = math.sin(yaw)}
if self.can_fly then
if current_pos.y >= (modes["fly"].max_height or 50) and not self.target then
@@ -585,7 +588,9 @@ creatures.on_step = function(self, dtime)
mod = me:getyaw()
end
local yaw = (getYaw(mod) + 90.0) * DEGTORAD
- me:setyaw(yaw + 4.73)
+ yaw = yaw + 4.73
+ yaw = yaw % (2 * math.pi)
+ me:setyaw(yaw)
local moving_speed = modes[current_mode].moving_speed or 0
if moving_speed > 0 then
self.dir = {x = math.cos(yaw), y = nil, z = math.sin(yaw)}
As there doesn't seem to be a definite fork/successor to this mod yet, I am posting this issue here.
While testing, I discovered that cme is computing the yaw of mobs in a strange fashion, which will cause the value to become larger than 360, and not simply by accident (I've seen values larger than 720 !). I am working on a minetest patch (minetest/minetest#4425) to prevent values that are too far out of range from causing problems, and it will reject values larger than 720. That means that cme mobs will cause lua errors after the PR is merged.
I created the following quick-and-dirty patch which will adjust the values before setting the yaw. I suppose somebody will want to create a better patch, that ensures the computed yaw will never become too large to begin with (although my PR will accept and adjust values up to 720).