mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-24 09:40:21 +01:00
added nil check for velocity
This commit is contained in:
parent
9c00616a00
commit
62bd960e38
5
api.lua
5
api.lua
@ -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)),
|
||||
|
Loading…
Reference in New Issue
Block a user