fix co-pilot routines

This commit is contained in:
Alexsandro Percy 2023-07-03 19:22:37 -03:00
parent 95087601fa
commit ffe03405f5
3 changed files with 19 additions and 16 deletions

View file

@ -96,10 +96,11 @@ function airutils.setText(self, vehicle_name)
end
function airutils.transfer_control(self, status)
if not self._have_copilot then return end
if status == false then
self._command_is_given = false
if self._passenger then
minetest.chat_send_player(self._passenger,
if self.co_pilot then
minetest.chat_send_player(self.co_pilot,
core.colorize('#ff0000', " >>> The captain got the control."))
end
if self.driver_name then
@ -108,8 +109,8 @@ function airutils.transfer_control(self, status)
end
else
self._command_is_given = true
if self._passenger then
minetest.chat_send_player(self._passenger,
if self.co_pilot then
minetest.chat_send_player(self.co_pilot,
core.colorize('#00ff00', " >>> The control is with you now."))
end
if self.driver_name then minetest.chat_send_player(self.driver_name," >>> The control was given.") end

View file

@ -159,15 +159,15 @@ function airutils.logic(self)
local player = nil
if self.driver_name then player = minetest.get_player_by_name(self.driver_name) end
local passenger = nil
if self._passenger then passenger = minetest.get_player_by_name(self._passenger) end
local co_pilot = nil
if self.co_pilot and self._have_copilot then co_pilot = minetest.get_player_by_name(self.co_pilot) end
if player then
local ctrl = player:get_player_control()
---------------------
-- change the driver
---------------------
if passenger and self._last_time_command >= 1 and self._instruction_mode == true then
if co_pilot and self._have_copilot and self._last_time_command >= 1 and self._instruction_mode == true then
if self._command_is_given == true then
if ctrl.sneak or ctrl.jump or ctrl.up or ctrl.down or ctrl.right or ctrl.left then
self._last_time_command = 0
@ -175,11 +175,11 @@ function airutils.logic(self)
airutils.transfer_control(self, false)
end
else
if ctrl.sneak == true and ctrl.jump == true then
--[[if ctrl.sneak == true and ctrl.jump == true then
self._last_time_command = 0
--trasnfer the control to student
airutils.transfer_control(self, true)
end
end]]--
end
end
-----------
@ -353,16 +353,18 @@ function airutils.logic(self)
-- end roll
local pilot = player
if self._command_is_given and passenger then
pilot = passenger
else
self._command_is_given = false
if self._have_copilot then
if self._command_is_given and co_pilot then
pilot = co_pilot
else
self._command_is_given = false
end
end
------------------------------------------------------
--accell calculation block
------------------------------------------------------
if is_attached or passenger then
if is_attached or co_pilot then
if self._autopilot ~= true then
accel, stop = airutils.control(self, self.dtime, hull_direction,
longit_speed, longit_drag, later_speed, later_drag, accel, pilot, is_flying)

View file

@ -181,8 +181,8 @@ function airutils.dettach_pax(self, player)
local name = player:get_player_name() --self._passenger
-- passenger clicked the object => driver gets off the vehicle
if self._passenger == name then
self._passenger = nil
if self.co_pilot == name then
self.co_pilot = nil
else
local max_seats = table.getn(self._seats)
for i = max_seats,1,-1