added nil check for velocity

This commit is contained in:
tenplus1 2020-02-26 21:28:04 +00:00
parent 9c00616a00
commit 62bd960e38
1 changed files with 4 additions and 1 deletions

View File

@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
version = "20200207",
version = "20200226",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -230,6 +230,9 @@ function mob_class:set_velocity(v)
local yaw = (self.object:get_yaw() or 0) + self.rotate
-- nil check for velocity
v = v or 0
-- set velocity with hard limit of 10
self.object:set_velocity({
x = max(-10, min((sin(yaw) * -v) + c_x, 10)),