improved copilot attachment

This commit is contained in:
Alexsandro Percy 2023-07-15 12:25:14 -03:00
parent 32ba21c3fd
commit 86432a1979

View file

@ -108,18 +108,7 @@ function airutils.check_passenger_is_attached(self, name)
return is_attached
end
-- attach passenger
function airutils.attach_pax(self, player, is_copilot)
local is_copilot = is_copilot or false
local name = player:get_player_name()
local eye_y = -4
if airutils.detect_player_api(player) == 1 then
eye_y = 2.5
end
if is_copilot == true then
if self.co_pilot == nil then
local function attach_copilot(self, name, player, eye_y)
self.co_pilot = name
self._passengers[2] = name
-- attach the driver
@ -136,6 +125,21 @@ function airutils.attach_pax(self, player, is_copilot)
end
end)
end
-- attach passenger
function airutils.attach_pax(self, player, is_copilot)
local is_copilot = is_copilot or false
local name = player:get_player_name()
local eye_y = -4
if airutils.detect_player_api(player) == 1 then
eye_y = 2.5
end
if is_copilot == true then
if self.co_pilot == nil then
attach_copilot(self, name, player, eye_y)
end
else
--randomize the seat
local max_seats = table.getn(self._seats)
@ -143,20 +147,7 @@ function airutils.attach_pax(self, player, is_copilot)
if self._have_copilot and max_seats > 2 then
crew = crew + 1
else
self.co_pilot = name
player:set_attach(self.co_pilot_seat_base, "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
player:set_eye_offset({x = 0, y = eye_y, z = 0}, {x = 0, y = 3, z = -30})
player_api.player_attached[name] = true
player_api.set_animation(player, "sit")
-- make the driver sit
minetest.after(1, function()
player = minetest.get_player_by_name(name)
if player then
airutils.sit(player)
--apply_physics_override(player, {speed=0,gravity=0,jump=0})
end
end)
attach_copilot(self, name, player, eye_y)
return
end