replace get_look_yaw with get_look_horizontal and add nil check for driver
This commit is contained in:
parent
74fc8110c1
commit
4f22460ff2
24
api.lua
24
api.lua
@ -60,7 +60,8 @@ function object_attach(entity, player, attach_at, eye_offset)
|
|||||||
minetest.after(0.2, function()
|
minetest.after(0.2, function()
|
||||||
default.player_set_animation(player, "sit" , 30)
|
default.player_set_animation(player, "sit" , 30)
|
||||||
end)
|
end)
|
||||||
entity.object:set_yaw(player:get_look_yaw() - math.pi / 2)
|
--entity.object:set_yaw(player:get_look_yaw() - math.pi / 2)
|
||||||
|
entity.object:set_yaw(player:get_look_horizontal() - math.pi / 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
function object_detach(entity, player, offset)
|
function object_detach(entity, player, offset)
|
||||||
@ -97,14 +98,16 @@ end)
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
--mixed code(from this mod and lib_mount)
|
--mixed code(from this mod and lib_mount)
|
||||||
|
local rotview = math.pi / 2
|
||||||
|
|
||||||
function object_drive(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim, jumps)
|
function object_drive(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim, jumps)
|
||||||
local ctrl = entity.driver:get_player_control()
|
local ctrl = entity.driver:get_player_control()
|
||||||
local dir = entity.driver:get_look_dir();
|
local dir = entity.driver:get_look_dir()
|
||||||
local vec_forward = {x=dir.x*speed,y=-2,z=dir.z*speed}
|
local vec_forward = {x=dir.x*speed,y=-2,z=dir.z*speed}
|
||||||
local vec_backward = {x=-dir.x*speed,y=-2,z=-dir.z*speed}
|
local vec_backward = {x=-dir.x*speed,y=-2,z=-dir.z*speed}
|
||||||
local vec_stop = {x=0,y=0,z=0}
|
local vec_stop = {x=0,y=0,z=0}
|
||||||
local yaw = entity.driver:get_look_yaw();
|
--local yaw = entity.driver:get_look_yaw()
|
||||||
|
local yaw = entity.driver:get_look_horizontal()
|
||||||
if ctrl.up then
|
if ctrl.up then
|
||||||
entity.object:set_yaw(yaw+math.pi+math.pi/2)
|
entity.object:set_yaw(yaw+math.pi+math.pi/2)
|
||||||
entity.object:set_velocity(vec_forward)
|
entity.object:set_velocity(vec_forward)
|
||||||
@ -119,7 +122,7 @@ function object_drive(entity, dtime, speed, shoots, arrow, moving_anim, stand_an
|
|||||||
local pos = entity.object:get_pos()
|
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 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 vec = {x=dir.x*6,y=dir.y*6,z=dir.z*6}
|
||||||
local yaw = entity.driver:get_look_yaw();
|
local yaw = entity.driver:get_look_horizontal() + rotview
|
||||||
obj:set_yaw(yaw+math.pi/2)
|
obj:set_yaw(yaw+math.pi/2)
|
||||||
obj:set_velocity(vec)
|
obj:set_velocity(vec)
|
||||||
end
|
end
|
||||||
@ -150,14 +153,17 @@ function object_drive(entity, dtime, speed, shoots, arrow, moving_anim, stand_an
|
|||||||
end
|
end
|
||||||
|
|
||||||
function object_fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
function object_fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
||||||
|
|
||||||
|
if entity and not entity.driver then return end
|
||||||
|
|
||||||
local ctrl = entity.driver:get_player_control()
|
local ctrl = entity.driver:get_player_control()
|
||||||
local velo = entity.object:get_velocity()
|
local velo = entity.object:get_velocity()
|
||||||
local dir = entity.driver:get_look_dir();
|
local dir = entity.driver:get_look_dir()
|
||||||
local vec_forward = {x=dir.x*speed,y=dir.y*speed+2,z=dir.z*speed}
|
local vec_forward = {x=dir.x*speed,y=dir.y*speed+2,z=dir.z*speed}
|
||||||
local vec_backward = {x=-dir.x*speed,y=dir.y*speed+2,z=-dir.z*speed}
|
local vec_backward = {x=-dir.x*speed,y=dir.y*speed+2,z=-dir.z*speed}
|
||||||
local vec_rise = {x=velo.x,y=velo.y+0.2,z=velo.z}
|
local vec_rise = {x=velo.x,y=velo.y+0.2,z=velo.z}
|
||||||
local vec_stop = {x=0,y=-0.2,z=0}
|
local vec_stop = {x=0,y=-0.2,z=0}
|
||||||
local yaw = entity.driver:get_look_yaw();
|
local yaw = entity.driver:get_look_horizontal() + rotview
|
||||||
local pos = entity.object:get_pos()
|
local pos = entity.object:get_pos()
|
||||||
local node = minetest.get_node(pos).name
|
local node = minetest.get_node(pos).name
|
||||||
|
|
||||||
@ -182,7 +188,8 @@ function object_fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim
|
|||||||
local pos = entity.object:get_pos()
|
local pos = entity.object:get_pos()
|
||||||
local obj = minetest.add_entity({x=pos.x+0+dir.x*2.5,y=pos.y+1.5+dir.y,z=pos.z+0+dir.z*2.5}, arrow)
|
local obj = minetest.add_entity({x=pos.x+0+dir.x*2.5,y=pos.y+1.5+dir.y,z=pos.z+0+dir.z*2.5}, arrow)
|
||||||
local vec = vector.multiply(dir, 12)
|
local vec = vector.multiply(dir, 12)
|
||||||
local yaw = entity.driver:get_look_yaw();
|
--local yaw = entity.driver:get_look_yaw()
|
||||||
|
local yaw = entity.driver:get_look_horizontal()
|
||||||
entity.loaded = true
|
entity.loaded = true
|
||||||
obj:set_yaw(yaw+math.pi/2)
|
obj:set_yaw(yaw+math.pi/2)
|
||||||
obj:set_velocity(vec)
|
obj:set_velocity(vec)
|
||||||
@ -247,7 +254,8 @@ function lib_mount.attach(entity, player, attach_at, eye_offset)
|
|||||||
minetest.after(0.2, function()
|
minetest.after(0.2, function()
|
||||||
default.player_set_animation(player, "sit" , 30)
|
default.player_set_animation(player, "sit" , 30)
|
||||||
end)
|
end)
|
||||||
entity.object:set_yaw(player:get_look_yaw() - math.pi / 2)
|
-- --entity.object:set_yaw(player:get_look_yaw() - math.pi / 2)
|
||||||
|
-- entity.object:set_yaw(player:get_look_horizontal() - math.pi / 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
function lib_mount.detach(entity, player, offset)
|
function lib_mount.detach(entity, player, offset)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user