add wiggle rotation nil check

This commit is contained in:
Juraj Vajda 2022-10-22 17:54:46 -04:00
parent 1b635974ab
commit f719b697e3

46
api.lua
View File

@ -1262,31 +1262,35 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
---Wiggle ---Wiggle
local rotation = selfObj.object:get_rotation() local rotation = selfObj.object:get_rotation()
local wiggle_timer_const = 0.05
local wiggle_timer = 0
for i = 1, 3 do if rotation then
local rotx = rotation.x + math.random(10, 20) / 100 local wiggle_timer_const = 0.05
local wiggle_timer = 0
if i % 2 == 0 then for i = 1, 3 do
rotx = rotation.x - math.random(10, 20) / 100 local rotx = rotation.x + math.random(10, 20) / 100
if i % 2 == 0 then
rotx = rotation.x - math.random(10, 20) / 100
end
local _rotation = {
x = rotx,
y = rotation.y,
z = rotation.z
}
if i == 3 then
_rotation = rotation
end
wiggle_timer = wiggle_timer + wiggle_timer_const
minetest.after(wiggle_timer, function(v_object)
selfObj.object:set_rotation(_rotation)
end, selfObj.object, wiggle_timer)
end end
local _rotation = {
x = rotx,
y = rotation.y,
z = rotation.z
}
if i == 3 then
_rotation = rotation
end
wiggle_timer = wiggle_timer + wiggle_timer_const
minetest.after(wiggle_timer, function(v_object)
selfObj.object:set_rotation(_rotation)
end, selfObj.object, wiggle_timer)
end end
---API callbacks ---API callbacks