menu improved

This commit is contained in:
Alexsandro Percy 2023-07-07 22:23:56 -03:00
parent 92746d795e
commit 19b3423e43
2 changed files with 21 additions and 19 deletions

View file

@ -21,8 +21,6 @@ function airutils.pilot_formspec(name)
end end
local ent = plane_obj:get_luaentity() local ent = plane_obj:get_luaentity()
local extra_height = 0
local flap_is_down = "false" local flap_is_down = "false"
local have_flaps = false local have_flaps = false
if ent._wing_angle_extra_flaps then if ent._wing_angle_extra_flaps then
@ -32,25 +30,19 @@ function airutils.pilot_formspec(name)
end end
if have_flaps then if have_flaps then
if ent._flap then flap_is_down = "true" end if ent._flap then flap_is_down = "true" end
extra_height = extra_height + 0.5
end end
local light = "false" local light = "false"
if ent._have_landing_lights then if ent._have_landing_lights then
if ent._land_light then light = "true" end if ent._land_light then light = "true" end
extra_height = extra_height + 0.5
end end
if ent._have_copilot and name == ent.driver_name then extra_height = extra_height + 1.1 end
if ent._have_adf then extra_height = extra_height + 1.1 end
local yaw = "false" local yaw = "false"
if ent._yaw_by_mouse then yaw = "true" end if ent._yaw_by_mouse then yaw = "true" end
local basic_form = table.concat({ local basic_form = table.concat({
"formspec_version[3]", "formspec_version[3]",
"size[6.0,"..(7.0+extra_height).."]", "size[11.0,7.4]",
}, "") }, "")
local ver_pos = 1.0 local ver_pos = 1.0
@ -59,32 +51,37 @@ function airutils.pilot_formspec(name)
basic_form = basic_form.."button[1,"..ver_pos..";4,1;hud;Show/Hide Gauges]" basic_form = basic_form.."button[1,"..ver_pos..";4,1;hud;Show/Hide Gauges]"
ver_pos = ver_pos + 1.1 ver_pos = ver_pos + 1.1
basic_form = basic_form.."button[1,"..ver_pos..";4,1;inventory;Show Inventory]" basic_form = basic_form.."button[1,"..ver_pos..";4,1;inventory;Show Inventory]"
ver_pos = ver_pos + 1.5 ver_pos = ver_pos + 2.2
basic_form = basic_form.."button[1,"..ver_pos..";4,1;go_out;Go Out!]"
ver_pos = 1.2 --restart in second collumn
if have_flaps then if have_flaps then
basic_form = basic_form.."checkbox[1,"..ver_pos..";flap_is_down;Flaps down;"..flap_is_down.."]" basic_form = basic_form.."checkbox[6,"..ver_pos..";flap_is_down;Flaps down;"..flap_is_down.."]"
ver_pos = ver_pos + 0.5 ver_pos = ver_pos + 0.5
end end
if ent._have_landing_lights then if ent._have_landing_lights then
basic_form = basic_form.."checkbox[1,"..ver_pos..";light;Landing Light;"..light.."]" basic_form = basic_form.."checkbox[6,"..ver_pos..";light;Landing Light;"..light.."]"
ver_pos = ver_pos + 0.5 ver_pos = ver_pos + 0.5
end end
basic_form = basic_form.."checkbox[1,"..ver_pos..";yaw;Yaw by mouse;"..yaw.."]" basic_form = basic_form.."checkbox[6,"..ver_pos..";yaw;Yaw by mouse;"..yaw.."]"
ver_pos = ver_pos + 0.5 ver_pos = ver_pos + 0.5
if ent._have_copilot and name == ent.driver_name then if ent._have_copilot and name == ent.driver_name then
basic_form = basic_form.."button[1,"..ver_pos..";4,1;copilot_form;Co-pilot Manager]" basic_form = basic_form.."button[6,"..ver_pos..";4,1;copilot_form;Co-pilot Manager]"
ver_pos = ver_pos + 1.1 ver_pos = ver_pos + 1.1
end end
if ent._have_adf then if ent._have_adf then
basic_form = basic_form.."button[1,"..ver_pos..";4,1;adf_form;Adf Manager]" basic_form = basic_form.."button[6,"..ver_pos..";4,1;adf_form;Adf Manager]"
ver_pos = ver_pos + 1.1 ver_pos = ver_pos + 1.1
end end
basic_form = basic_form.."button[1,"..ver_pos..";4,1;go_out;Go Out!]" if ent._have_manual then
basic_form = basic_form.."button[6,5.4;4,1;manual;Manual]"
end
minetest.show_formspec(name, "lib_planes:pilot_main", basic_form) minetest.show_formspec(name, "lib_planes:pilot_main", basic_form)
end end
@ -344,6 +341,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.adf_form then if fields.adf_form then
airutils.adf_formspec(name) airutils.adf_formspec(name)
end end
if fields.manual then
if ent._have_manual then
ent._have_manual(name)
end
end
end end
minetest.close_formspec(name, "lib_planes:pilot_main") minetest.close_formspec(name, "lib_planes:pilot_main")
end end

View file

@ -446,9 +446,10 @@ function airutils.engineSoundPlay(self)
--sound --sound
if self.sound_handle then minetest.sound_stop(self.sound_handle) end if self.sound_handle then minetest.sound_stop(self.sound_handle) end
if self.object then if self.object then
local pitch_adjust = 0.5 + ((self._power_lever/100)/2)
self.sound_handle = minetest.sound_play({name = self._engine_sound}, self.sound_handle = minetest.sound_play({name = self._engine_sound},
{object = self.object, gain = 2.0, {object = self.object, gain = 2.0,
pitch = 0.5 + ((self._power_lever/100)/2), pitch = pitch_adjust,
max_hear_distance = 15, max_hear_distance = 15,
loop = true,}) loop = true,})
end end
@ -457,8 +458,7 @@ end
function airutils.engine_set_sound_and_animation(self) function airutils.engine_set_sound_and_animation(self)
--minetest.chat_send_all('test1 ' .. dump(self._engine_running) ) --minetest.chat_send_all('test1 ' .. dump(self._engine_running) )
if self._engine_running then if self._engine_running then
if self._last_applied_power ~= self._power_lever then if self._last_applied_power ~= self._power_lever and not self._autopilot then
--minetest.chat_send_all('test2')
self._last_applied_power = self._power_lever self._last_applied_power = self._power_lever
self.object:set_animation_frame_speed(60 + self._power_lever) self.object:set_animation_frame_speed(60 + self._power_lever)
airutils.engineSoundPlay(self) airutils.engineSoundPlay(self)