passenger/driver fixes
This commit is contained in:
parent
e2be829ff9
commit
6fb82df894
49
init.lua
49
init.lua
@ -55,10 +55,12 @@ end
|
|||||||
|
|
||||||
local function force_detach(player)
|
local function force_detach(player)
|
||||||
local attached_to = player:get_attach()
|
local attached_to = player:get_attach()
|
||||||
if attached_to and attached_to:get_luaentity() then
|
if attached_to then
|
||||||
local entity = attached_to:get_luaentity()
|
local entity = attached_to:get_luaentity()
|
||||||
if entity.driver then
|
if entity.driver and entity.driver == player then
|
||||||
entity.driver = nil
|
entity.driver = nil
|
||||||
|
elseif entity.passenger and entity.passenger == player then
|
||||||
|
entity.passenger = nil
|
||||||
end
|
end
|
||||||
player:set_detach()
|
player:set_detach()
|
||||||
default.player_attached[player:get_player_name()] = false
|
default.player_attached[player:get_player_name()] = false
|
||||||
@ -90,26 +92,45 @@ end)
|
|||||||
|
|
||||||
lib_mount = {}
|
lib_mount = {}
|
||||||
|
|
||||||
function lib_mount.attach(entity, player, attach_at, eye_offset, rotation)
|
function lib_mount.attach(entity, player, is_passenger)
|
||||||
eye_offset = eye_offset or {x=0, y=0, z=0}
|
local attach_at, eye_offset = {}, {}
|
||||||
rotation = rotation or {x=0, y=0, z=0}
|
|
||||||
|
|
||||||
if not entity.player_rotation then
|
if not entity.player_rotation then
|
||||||
entity.player_rotation = rotation
|
entity.player_rotation = {x=0, y=0, z=0}
|
||||||
end
|
end
|
||||||
|
|
||||||
local rot_view = 0
|
local rot_view = 0
|
||||||
if rotation.y == 90 then
|
if entity.player_rotation.y == 90 then
|
||||||
rot_view = math.pi/2
|
rot_view = math.pi/2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if is_passenger == true then
|
||||||
|
if not entity.passenger_attach_at then
|
||||||
|
entity.passenger_attach_at = {x=0, y=0, z=0}
|
||||||
|
end
|
||||||
|
if not entity.passenger_eye_offset then
|
||||||
|
entity.passenger_eye_offset = {x=0, y=0, z=0}
|
||||||
|
end
|
||||||
|
attach_at = entity.passenger_attach_at
|
||||||
|
eye_offset = entity.passenger_eye_offset
|
||||||
|
entity.passenger = player
|
||||||
|
else
|
||||||
|
if not entity.driver_attach_at then
|
||||||
|
entity.driver_attach_at = {x=0, y=0, z=0}
|
||||||
|
end
|
||||||
|
if not entity.driver_eye_offset then
|
||||||
|
entity.driver_eye_offset = {x=0, y=0, z=0}
|
||||||
|
end
|
||||||
|
attach_at = entity.driver_attach_at
|
||||||
|
eye_offset = entity.driver_eye_offset
|
||||||
|
entity.driver = player
|
||||||
|
end
|
||||||
|
|
||||||
force_detach(player)
|
force_detach(player)
|
||||||
entity.driver = player
|
|
||||||
player:set_attach(entity.object, "", attach_at, rotation)
|
player:set_attach(entity.object, "", attach_at, entity.player_rotation)
|
||||||
|
|
||||||
player:set_properties({visual_size = {x=1, y=1}})
|
|
||||||
|
|
||||||
player:set_eye_offset(eye_offset, {x=0, y=0, z=0})
|
|
||||||
default.player_attached[player:get_player_name()] = true
|
default.player_attached[player:get_player_name()] = true
|
||||||
|
player:set_eye_offset(eye_offset, {x=0, y=0, z=0})
|
||||||
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user