improving copilot and instruction mode

This commit is contained in:
Alexsandro Percy 2023-07-14 21:08:19 -03:00
parent be2f9cccc2
commit 1b8caaf7c4
3 changed files with 31 additions and 3 deletions

View File

@ -784,10 +784,14 @@ function airutils.on_rightclick(self, clicker)
if clicker:get_player_control().sneak == true then
-- flight instructor mode
self._instruction_mode = true
airutils.attach(self, clicker, true)
self.co_pilot_seat_base = self._passengers_base[1]
self.pilot_seat_base = self._passengers_base[2]
airutils.attach(self, clicker)
else
-- no driver => clicker is new driver
self._instruction_mode = false
self.co_pilot_seat_base = self._passengers_base[2]
self.pilot_seat_base = self._passengers_base[1]
airutils.attach(self, clicker)
end
self._command_is_given = false

View File

@ -126,7 +126,12 @@ function airutils.manage_copilot_formspec(name)
}, "")
basic_form = basic_form.."label[1,1.0;Bring a copilot:]"
local max_seats = table.getn(ent._seats)
if ent._have_copilot and max_seats > 2 then --no need to select if there are only 2 occupants
basic_form = basic_form.."dropdown[1,1.5;4,0.6;copilot;"..pass_list..";0;false]"
end
basic_form = basic_form.."button[1,2.5;4,1;pass_control;Pass the Control]"
minetest.show_formspec(name, "lib_planes:manage_copilot", basic_form)

View File

@ -140,7 +140,26 @@ function airutils.attach_pax(self, player, is_copilot)
--randomize the seat
local max_seats = table.getn(self._seats)
local crew = 1
if self._have_copilot and max_seats > 2 then crew = crew + 1 end
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)
return
end
t = {} -- new array
for i=1, max_seats - crew do --(the first are for the crew
t[i] = i