mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 04:21:07 +01:00
Move old set_yaw and add node on set_velocity
This commit is contained in:
parent
e53a193c4f
commit
9e4bf6e130
2 changed files with 34 additions and 32 deletions
|
@ -228,6 +228,9 @@ end
|
|||
|
||||
|
||||
-- move mob in facing direction
|
||||
--this has been modified to be internal
|
||||
--internal = lua (self.yaw)
|
||||
--engine = c++ (self.object:get_yaw())
|
||||
local set_velocity = function(self, v)
|
||||
|
||||
local yaw = (self.yaw or 0)
|
||||
|
@ -271,37 +274,6 @@ local get_velocity = function(self)
|
|||
return 0
|
||||
end
|
||||
|
||||
|
||||
-- set and return valid yaw
|
||||
local set_yaw = function(self, yaw, delay, dtime)
|
||||
|
||||
if not yaw or yaw ~= yaw then
|
||||
yaw = 0
|
||||
end
|
||||
|
||||
delay = delay or 0
|
||||
|
||||
if delay == 0 then
|
||||
if self.shaking and dtime then
|
||||
yaw = yaw + (math_random() * 2 - 1) * 5 * dtime
|
||||
end
|
||||
self.yaw(yaw)
|
||||
update_roll(self)
|
||||
return yaw
|
||||
end
|
||||
|
||||
self.target_yaw = yaw
|
||||
self.delay = delay
|
||||
|
||||
return self.target_yaw
|
||||
end
|
||||
|
||||
-- global function to set mob yaw
|
||||
function mobs:yaw(self, yaw, delay, dtime)
|
||||
set_yaw(self, yaw, delay, dtime)
|
||||
end
|
||||
|
||||
|
||||
-- set defined animation
|
||||
local set_animation = function(self, anim, fixed_frame)
|
||||
if not self.animation or not anim then
|
||||
|
|
|
@ -3267,3 +3267,33 @@ local create_mob_on_rightclick = function(on_rightclick)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- set and return valid yaw
|
||||
local set_yaw = function(self, yaw, delay, dtime)
|
||||
|
||||
if not yaw or yaw ~= yaw then
|
||||
yaw = 0
|
||||
end
|
||||
|
||||
delay = delay or 0
|
||||
|
||||
if delay == 0 then
|
||||
if self.shaking and dtime then
|
||||
yaw = yaw + (math_random() * 2 - 1) * 5 * dtime
|
||||
end
|
||||
self.yaw(yaw)
|
||||
update_roll(self)
|
||||
return yaw
|
||||
end
|
||||
|
||||
self.target_yaw = yaw
|
||||
self.delay = delay
|
||||
|
||||
return self.target_yaw
|
||||
end
|
||||
|
||||
|
||||
-- global function to set mob yaw
|
||||
function mobs:yaw(self, yaw, delay, dtime)
|
||||
set_yaw(self, yaw, delay, dtime)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue