workaround for lib_mount copy api on commented line set_yaw

* documented at https://notabug.org/TenPlus1/dmobs/issues/11#issuecomment-29714
* we do not need all the current lib_mount.attach features, so ony change deprecated
* a (math.pi/2) around parenthesis do be sure of the values
main-namespace_mobs
Герхард PICCORO Lenz McKAY 2022-01-25 09:51:24 -04:00
parent ffe3a46f82
commit 5ff7d64b48
1 changed files with 12 additions and 13 deletions

25
api.lua
View File

@ -61,7 +61,7 @@ function object_attach(entity, player, attach_at, eye_offset)
default.player_set_animation(player, "sit" , 30)
end)
--entity.object:set_yaw(player:get_look_yaw() - math.pi / 2)
entity.object:set_yaw(player:get_look_horizontal() - math.pi / 2)
entity.object:set_yaw(player:get_look_horizontal() - (math.pi/2))
end
function object_detach(entity, player, offset)
@ -119,21 +119,21 @@ function object_drive(entity, dtime, speed, shoots, arrow, moving_anim, stand_an
--local yaw = entity.driver:get_look_yaw()
local yaw = entity.driver:get_look_horizontal()
if ctrl.up then
entity.object:set_yaw(yaw+math.pi+math.pi/2)
entity.object:set_yaw(yaw+math.pi+math.pi/2) -- check math.pi+math.pi/2 check if the order of the signs is correct
entity.object:set_velocity(vec_forward)
elseif ctrl.down then
entity.object:set_yaw(yaw+math.pi+math.pi/2)
entity.object:set_yaw(yaw+math.pi+math.pi/2) -- check math.pi+math.pi/2 check if the order of the signs is correct
entity.object:set_velocity(vec_backward)
elseif not ctrl.down or ctrl.up then
entity.object:set_yaw(yaw+math.pi+math.pi/2)
entity.object:set_yaw(yaw+math.pi+math.pi/2) -- check math.pi+math.pi/2 check if the order of the signs is correct
entity.object:set_velocity(vec_stop)
end
if ctrl.sneak and ctrl.LMB and shoots then
local pos = entity.object:get_pos()
local obj = minetest.add_entity({x=pos.x+0+dir.x*2,y=pos.y+1.5+dir.y,z=pos.z+0+dir.z*2}, arrow)
local vec = {x=dir.x*6,y=dir.y*6,z=dir.z*6}
local yaw = entity.driver:get_look_horizontal() + rotview
obj:set_yaw(yaw+math.pi/2)
local yaw = entity.driver:get_look_horizontal() + rotview -- we have math.pi/2 but later yaw sumarized again in next line
obj:set_yaw(yaw+math.pi/2) -- check math.pi+math.pi/2 check if the order of the signs is correct
obj:set_velocity(vec)
end
--lib_mount animation
@ -182,16 +182,16 @@ function object_fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim
-- entity.object:set_velocity({x=velo.x*0.5, y=velo.y*0.5, z=velo.z*0.5})
-- end
if ctrl.up then
entity.object:set_yaw(yaw+math.pi+math.pi/2)
entity.object:set_yaw(yaw+math.pi+math.pi/2) -- check math.pi+math.pi/2 check if the order of the signs is correct
entity.object:set_velocity(vec_forward)
elseif ctrl.down then
entity.object:set_yaw(yaw+math.pi+math.pi/2)
entity.object:set_yaw(yaw+math.pi+math.pi/2) -- check math.pi+math.pi/2 check if the order of the signs is correct
entity.object:set_velocity(vec_backward)
elseif ctrl.jump then
entity.object:set_yaw(yaw+math.pi+math.pi/2)
entity.object:set_yaw(yaw+math.pi+math.pi/2) -- check math.pi+math.pi/2 check if the order of the signs is correct
entity.object:set_velocity(vec_rise)
elseif not ctrl.down or ctrl.up or ctrl.jump then
entity.object:set_yaw(yaw+math.pi+math.pi/2)
entity.object:set_yaw(yaw+math.pi+math.pi/2) -- check math.pi+math.pi/2 check if the order of the signs is correct
entity.object:set_velocity(vec_stop)
end
if ctrl.aux1 and shoots and not entity.loaded then
@ -201,7 +201,7 @@ function object_fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim
--local yaw = entity.driver:get_look_yaw()
local yaw = entity.driver:get_look_horizontal()
entity.loaded = true
obj:set_yaw(yaw+math.pi/2)
obj:set_yaw(yaw+math.pi/2) -- check math.pi+math.pi/2 check if the order of the signs is correct
obj:set_velocity(vec)
local object = obj:get_luaentity()
object.launcher = entity.driver
@ -264,8 +264,7 @@ function lib_mount.attach(entity, player, attach_at, eye_offset)
minetest.after(0.2, function()
default.player_set_animation(player, "sit" , 30)
end)
-- --entity.object:set_yaw(player:get_look_yaw() - math.pi / 2)
-- entity.object:set_yaw(player:get_look_horizontal() - math.pi / 2)
entity.object:set_look_horizontal(player:get_look_horizontal() - (math.pi/2))
end
function lib_mount.detach(entity, player, offset)