From f7065a27668ef7e28a085a95a586701f60af5c7a Mon Sep 17 00:00:00 2001 From: Alexsandro Percy Date: Thu, 6 Jul 2023 20:25:01 -0300 Subject: [PATCH] added adf specific methods --- lib_planes/entities.lua | 1 + lib_planes/forms.lua | 14 ++++++++++++-- lib_planes/utilities.lua | 12 ++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib_planes/entities.lua b/lib_planes/entities.lua index 94ea05b..dbbb0ac 100644 --- a/lib_planes/entities.lua +++ b/lib_planes/entities.lua @@ -153,6 +153,7 @@ end function airutils.logic(self) local velocity = self.object:get_velocity() local curr_pos = self.object:get_pos() + self._curr_pos = curr_pos --shared self._last_time_command = self._last_time_command + self.dtime diff --git a/lib_planes/forms.lua b/lib_planes/forms.lua index 3e972e0..af86c23 100644 --- a/lib_planes/forms.lua +++ b/lib_planes/forms.lua @@ -43,6 +43,8 @@ function airutils.pilot_formspec(name) 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" if ent._yaw_by_mouse then yaw = "true" end @@ -68,12 +70,17 @@ function airutils.pilot_formspec(name) basic_form = basic_form.."checkbox[1,"..ver_pos..";light;Landing Light;"..light.."]" ver_pos = ver_pos + 0.5 end - + basic_form = basic_form.."checkbox[1,"..ver_pos..";yaw;Yaw by mouse;"..yaw.."]" ver_pos = ver_pos + 0.5 if ent._have_copilot and name == ent.driver_name then - basic_form = basic_form.."button[1,"..ver_pos..";4,1;copilot_form;Co-pilot Manage]" + basic_form = basic_form.."button[1,"..ver_pos..";4,1;copilot_form;Co-pilot Manager]" + ver_pos = ver_pos + 1.1 + end + + if ent._have_adf then + basic_form = basic_form.."button[1,"..ver_pos..";4,1;adf_form;Adf Manager]" ver_pos = ver_pos + 1.1 end @@ -334,6 +341,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if fields.copilot_form then airutils.manage_copilot_formspec(name) end + if fields.adf_form then + airutils.adf_formspec(name) + end end minetest.close_formspec(name, "lib_planes:pilot_main") end diff --git a/lib_planes/utilities.lua b/lib_planes/utilities.lua index b67c687..bf410e7 100644 --- a/lib_planes/utilities.lua +++ b/lib_planes/utilities.lua @@ -850,3 +850,15 @@ function airutils.landing_lights_operate(self) end end end + +function airutils.get_adf_angle(self, pos) + local adf = 0 + if self._adf == true then + if airutils.getAngleFromPositions and self._adf_destiny then + adf = airutils.getAngleFromPositions(pos, self._adf_destiny) + adf = -(adf + math.deg(self._yaw)) + end + end + return adf +end +