mirror of
https://github.com/APercy/airutils.git
synced 2025-03-21 18:41:21 +00:00
fix co-pilot routines
This commit is contained in:
parent
95087601fa
commit
ffe03405f5
3 changed files with 19 additions and 16 deletions
9
init.lua
9
init.lua
|
@ -96,10 +96,11 @@ function airutils.setText(self, vehicle_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function airutils.transfer_control(self, status)
|
function airutils.transfer_control(self, status)
|
||||||
|
if not self._have_copilot then return end
|
||||||
if status == false then
|
if status == false then
|
||||||
self._command_is_given = false
|
self._command_is_given = false
|
||||||
if self._passenger then
|
if self.co_pilot then
|
||||||
minetest.chat_send_player(self._passenger,
|
minetest.chat_send_player(self.co_pilot,
|
||||||
core.colorize('#ff0000', " >>> The captain got the control."))
|
core.colorize('#ff0000', " >>> The captain got the control."))
|
||||||
end
|
end
|
||||||
if self.driver_name then
|
if self.driver_name then
|
||||||
|
@ -108,8 +109,8 @@ function airutils.transfer_control(self, status)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self._command_is_given = true
|
self._command_is_given = true
|
||||||
if self._passenger then
|
if self.co_pilot then
|
||||||
minetest.chat_send_player(self._passenger,
|
minetest.chat_send_player(self.co_pilot,
|
||||||
core.colorize('#00ff00', " >>> The control is with you now."))
|
core.colorize('#00ff00', " >>> The control is with you now."))
|
||||||
end
|
end
|
||||||
if self.driver_name then minetest.chat_send_player(self.driver_name," >>> The control was given.") end
|
if self.driver_name then minetest.chat_send_player(self.driver_name," >>> The control was given.") end
|
||||||
|
|
|
@ -159,15 +159,15 @@ function airutils.logic(self)
|
||||||
|
|
||||||
local player = nil
|
local player = nil
|
||||||
if self.driver_name then player = minetest.get_player_by_name(self.driver_name) end
|
if self.driver_name then player = minetest.get_player_by_name(self.driver_name) end
|
||||||
local passenger = nil
|
local co_pilot = nil
|
||||||
if self._passenger then passenger = minetest.get_player_by_name(self._passenger) end
|
if self.co_pilot and self._have_copilot then co_pilot = minetest.get_player_by_name(self.co_pilot) end
|
||||||
|
|
||||||
if player then
|
if player then
|
||||||
local ctrl = player:get_player_control()
|
local ctrl = player:get_player_control()
|
||||||
---------------------
|
---------------------
|
||||||
-- change the driver
|
-- 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 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
|
if ctrl.sneak or ctrl.jump or ctrl.up or ctrl.down or ctrl.right or ctrl.left then
|
||||||
self._last_time_command = 0
|
self._last_time_command = 0
|
||||||
|
@ -175,11 +175,11 @@ function airutils.logic(self)
|
||||||
airutils.transfer_control(self, false)
|
airutils.transfer_control(self, false)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if ctrl.sneak == true and ctrl.jump == true then
|
--[[if ctrl.sneak == true and ctrl.jump == true then
|
||||||
self._last_time_command = 0
|
self._last_time_command = 0
|
||||||
--trasnfer the control to student
|
--trasnfer the control to student
|
||||||
airutils.transfer_control(self, true)
|
airutils.transfer_control(self, true)
|
||||||
end
|
end]]--
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-----------
|
-----------
|
||||||
|
@ -353,16 +353,18 @@ function airutils.logic(self)
|
||||||
-- end roll
|
-- end roll
|
||||||
|
|
||||||
local pilot = player
|
local pilot = player
|
||||||
if self._command_is_given and passenger then
|
if self._have_copilot then
|
||||||
pilot = passenger
|
if self._command_is_given and co_pilot then
|
||||||
else
|
pilot = co_pilot
|
||||||
self._command_is_given = false
|
else
|
||||||
|
self._command_is_given = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
--accell calculation block
|
--accell calculation block
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
if is_attached or passenger then
|
if is_attached or co_pilot then
|
||||||
if self._autopilot ~= true then
|
if self._autopilot ~= true then
|
||||||
accel, stop = airutils.control(self, self.dtime, hull_direction,
|
accel, stop = airutils.control(self, self.dtime, hull_direction,
|
||||||
longit_speed, longit_drag, later_speed, later_drag, accel, pilot, is_flying)
|
longit_speed, longit_drag, later_speed, later_drag, accel, pilot, is_flying)
|
||||||
|
|
|
@ -181,8 +181,8 @@ function airutils.dettach_pax(self, player)
|
||||||
local name = player:get_player_name() --self._passenger
|
local name = player:get_player_name() --self._passenger
|
||||||
|
|
||||||
-- passenger clicked the object => driver gets off the vehicle
|
-- passenger clicked the object => driver gets off the vehicle
|
||||||
if self._passenger == name then
|
if self.co_pilot == name then
|
||||||
self._passenger = nil
|
self.co_pilot = nil
|
||||||
else
|
else
|
||||||
local max_seats = table.getn(self._seats)
|
local max_seats = table.getn(self._seats)
|
||||||
for i = max_seats,1,-1
|
for i = max_seats,1,-1
|
||||||
|
|
Loading…
Add table
Reference in a new issue