mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-24 09:40:21 +01:00
add some sanity checks
This commit is contained in:
parent
9c60e96336
commit
610cef16f4
11
api.lua
11
api.lua
@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20200326",
|
version = "20200406",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -254,6 +254,8 @@ function mob_class:get_velocity()
|
|||||||
|
|
||||||
local v = self.object:get_velocity()
|
local v = self.object:get_velocity()
|
||||||
|
|
||||||
|
if not v then return 0 end
|
||||||
|
|
||||||
return (v.x * v.x + v.z * v.z) ^ 0.5
|
return (v.x * v.x + v.z * v.z) ^ 0.5
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3115,7 +3117,10 @@ function mob_class:on_step(dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local yaw = 0
|
local yaw = self.object:get_yaw()
|
||||||
|
|
||||||
|
-- early warning check, if no yaw then no entity, skip rest of function
|
||||||
|
if not yaw then return end
|
||||||
|
|
||||||
-- get node at foot level every quarter second
|
-- get node at foot level every quarter second
|
||||||
self.node_timer = (self.node_timer or 0) + dtime
|
self.node_timer = (self.node_timer or 0) + dtime
|
||||||
@ -3164,8 +3169,6 @@ function mob_class:on_step(dtime)
|
|||||||
|
|
||||||
if self.delay and self.delay > 0 then
|
if self.delay and self.delay > 0 then
|
||||||
|
|
||||||
local yaw = self.object:get_yaw() or 0
|
|
||||||
|
|
||||||
if self.delay == 1 then
|
if self.delay == 1 then
|
||||||
yaw = self.target_yaw
|
yaw = self.target_yaw
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user