added the ADF function and ailerons are working now
parent
9d38a800c3
commit
a791976375
1
init.lua
1
init.lua
|
@ -42,6 +42,7 @@ ju52.textures = {
|
|||
"ju52_metal.png", "ju52_black.png", --manetes potencia
|
||||
"ju52_glass.png", --vidro porta
|
||||
"ju52_bege.png", --interno porta
|
||||
"ju52_compass_plan.png", --indicador ADF
|
||||
"ju52_engine.png", "ju52_black.png", --motor
|
||||
"ju52_engine.png", "ju52_black.png", --motores
|
||||
ju52.skin_texture, --fuselagem
|
||||
|
|
|
@ -113,6 +113,8 @@ minetest.register_entity("ju52:ju52", {
|
|||
_inv_id = "",
|
||||
_door_closed = true,
|
||||
_door_command = 1, --1 close, 0 open
|
||||
_adf = false,
|
||||
_adf_destiny = {x=0,z=0},
|
||||
|
||||
_change_color = function(self, colstr)
|
||||
airutils.paint(self, colstr, ju52.skin_texture)
|
||||
|
@ -129,6 +131,8 @@ minetest.register_entity("ju52:ju52", {
|
|||
stored_color = self._color,
|
||||
stored_skin = self._skin,
|
||||
stored_inv_id = self._inv_id,
|
||||
stored_adf = self._adf,
|
||||
stored_adf_destiny = self._adf_destiny,
|
||||
})
|
||||
end,
|
||||
|
||||
|
@ -149,6 +153,8 @@ minetest.register_entity("ju52:ju52", {
|
|||
self._color = data.stored_color
|
||||
self._skin = data.stored_skin
|
||||
self._inv_id = data.stored_inv_id
|
||||
self._adf = data.stored_adf
|
||||
self._adf_destiny = data.stored_adf_destiny
|
||||
--minetest.debug("loaded: ", self._energy)
|
||||
end
|
||||
airutils.setText(self, "Ju 52")
|
||||
|
@ -334,7 +340,8 @@ minetest.register_entity("ju52:ju52", {
|
|||
else
|
||||
local _,indx = item_name:find('dye:')
|
||||
if indx and self._engine_running == false then
|
||||
ju52.paint_formspec(self.owner)
|
||||
local name = puncher:get_player_name()
|
||||
ju52.paint_formspec(name)
|
||||
itmstck:set_count(itmstck:get_count()-1)
|
||||
puncher:set_wielded_item(itmstck)
|
||||
end
|
||||
|
|
|
@ -48,14 +48,39 @@ function ju52.pilot_formspec(name)
|
|||
local door_is_open = "true"
|
||||
if ent._door_closed then door_is_open = "false" end
|
||||
|
||||
local adf = "false"
|
||||
if ent._adf then adf = "true" end
|
||||
local x, z = 0
|
||||
if ent._adf_destiny then
|
||||
if ent._adf_destiny.x then
|
||||
if type(ent._adf_destiny.x) ~= nil then
|
||||
x = math.floor(ent._adf_destiny.x)
|
||||
end
|
||||
end
|
||||
if ent._adf_destiny.z then
|
||||
if type(ent._adf_destiny.z) ~= nil then
|
||||
z = math.floor(ent._adf_destiny.z)
|
||||
end
|
||||
end
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
local copilot_name = "test"
|
||||
basic_form = basic_form.."button[1,1.0;4,1;turn_on;Start/Stop Engines]"
|
||||
basic_form = basic_form.."button[1,2.0;4,1;hud;Show/Hide Gauges]"
|
||||
--basic_form = basic_form.."button[1,3.0;4,1;turn_auto_pilot_on;Auto Pilot]"
|
||||
basic_form = basic_form.."button[1,4.0;4,1;pass_control;Pass the Control]"
|
||||
basic_form = basic_form.."checkbox[1,5.8;flap_is_down;Flaps down;"..flap_is_down.."]"
|
||||
basic_form = basic_form.."checkbox[1,6.8;door_is_open;Door opened;"..door_is_open.."]"
|
||||
basic_form = basic_form.."button[1,7.8;4,1;go_out;Go Offboard]"
|
||||
basic_form = basic_form.."checkbox[1,5.4;flap_is_down;Flaps down;"..flap_is_down.."]"
|
||||
basic_form = basic_form.."checkbox[1,6.0;door_is_open;Door opened;"..door_is_open.."]"
|
||||
|
||||
basic_form = basic_form.."checkbox[1,7.0;adf;Auto Direction Find;"..adf.."]"
|
||||
basic_form = basic_form.."field[1,7.6;1.5,0.6;adf_x;pos x;"..x.."]"
|
||||
basic_form = basic_form.."field[2.7,7.6;1.5,0.6;adf_z;pos z;"..z.."]"
|
||||
basic_form = basic_form.."button[4.5,7.6;0.6,0.6;save_adf;OK]"
|
||||
|
||||
|
||||
basic_form = basic_form.."button[1,8.6;4,1;go_out;Go Offboard]"
|
||||
basic_form = basic_form.."label[1,10;Bring a copilot:]"
|
||||
basic_form = basic_form.."dropdown[1,10.2;4,1;copilot;"..pass_list..";0;false]"
|
||||
|
||||
|
@ -71,7 +96,7 @@ function ju52.paint_formspec(name)
|
|||
basic_form = basic_form.."image_button[0.5,0.5;3,1;ju52_p_lufthansa.png;lufthansa;Lufthansa;false;true;]"
|
||||
basic_form = basic_form.."image_button[0.5,1.6;3,1;ju52_p_lufthansa.png;lufthansa2;Lufthansa 2;false;true;]"
|
||||
basic_form = basic_form.."image_button[0.5,2.7;3,1;ju52_p_luftwaffe.png;luftwaffe;Luftwaffe;false;true;]"
|
||||
--basic_form = basic_form.."image_button[1,4.3;3,1;ju52_white.png^[multiply:#2b2b2b;black;Black;false;true;]"
|
||||
--basic_form = basic_form.."image_button[1,4.3;3,1;ju52_white.png^[multiply:#2b2b2b;black;Black;false;true;]"
|
||||
|
||||
minetest.show_formspec(name, "ju52:paint", basic_form)
|
||||
end
|
||||
|
@ -228,6 +253,28 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
end
|
||||
end
|
||||
end
|
||||
if fields.adf then
|
||||
if ent._adf == true then
|
||||
ent._adf = false
|
||||
else
|
||||
ent._adf = true
|
||||
end
|
||||
end
|
||||
if fields.save_adf then
|
||||
if ent._adf_destiny then
|
||||
if fields.adf_x then
|
||||
if tonumber(fields.adf_x, 10) ~= nil then
|
||||
ent._adf_destiny.x = tonumber(fields.adf_x, 10)
|
||||
end
|
||||
end
|
||||
if fields.adf_z then
|
||||
if tonumber(fields.adf_z, 10) ~= nil then
|
||||
ent._adf_destiny.z = tonumber(fields.adf_z, 10)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
minetest.close_formspec(name, "ju52:pilot_main")
|
||||
end
|
||||
|
|
|
@ -906,6 +906,19 @@ function ju52.flightstep(self)
|
|||
self.object:set_bone_position("fuel", {x=0, y=-40.6, z=15.35}, {x=0, y=(energy_indicator_angle+180), z=0})
|
||||
self.object:set_bone_position("compass", {x=0, y=-40.55, z=18.2}, {x=0, y=(math.deg(newyaw)), z=0})
|
||||
|
||||
local adf = 0
|
||||
if self._adf == true then
|
||||
if airutils.getAngleFromPositions then
|
||||
adf = airutils.getAngleFromPositions(curr_pos, self._adf_destiny)
|
||||
adf = (adf + math.deg(newyaw))
|
||||
--minetest.chat_send_all(adf)
|
||||
else
|
||||
minetest.chat_send_player(self.driver_name," >>> Impossible to activate the ADF - the airutils lib is outdated")
|
||||
end
|
||||
end
|
||||
|
||||
self.object:set_bone_position("compass_plan", {x=0, y=-40.4, z=18.2}, {x=0, y=adf, z=0})
|
||||
|
||||
--altimeters
|
||||
local altitude = (curr_pos.y / 0.32) / 100
|
||||
local hour, minutes = math.modf( altitude )
|
||||
|
@ -937,12 +950,13 @@ function ju52.flightstep(self)
|
|||
ju52.flap_off(self)
|
||||
end
|
||||
|
||||
--self.object:set_bone_position("l_aileron", {x=-93.79, y=4.8, z=6.5}, {x=6.7, y=0, z=97.25})
|
||||
--local l_aileron_rotation = {x=1, y=1, z=-2}
|
||||
--local l_aileron_rotation = vector.rotate_around_axis({x=6.7, y=5, z=97.25}, l_aileron_rotation, math.rad(30))
|
||||
--minetest.chat_send_all("x: " .. l_aileron_rotation.x .. " - y: " .. l_aileron_rotation.y .. " - z: " .. l_aileron_rotation.z)
|
||||
--self.object:set_bone_position("l_aileron", {x=-93.79, y=4.8, z=6.5}, l_aileron_rotation)
|
||||
self.object:set_bone_position("aileron_base_r", {x=93.79, y=4.8, z=6.5}, {x=-90, y=174.7, z=-7.4})
|
||||
local r_aileron_rotation = {x=0, y=-self._rudder_angle + 90, z=90}
|
||||
self.object:set_bone_position("r_aileron", {x=0, y=0, z=0}, r_aileron_rotation)
|
||||
|
||||
self.object:set_bone_position("aileron_base_l", {x=-93.79, y=4.8, z=6.5}, {x=90, y=5.3, z=7.4})
|
||||
local l_aileron_rotation = {x=0, y=-self._rudder_angle + 90, z=90}
|
||||
self.object:set_bone_position("l_aileron", {x=0, y=0, z=0}, r_aileron_rotation)
|
||||
|
||||
-- calculate energy consumption --
|
||||
ju52.consumptionCalc(self, accel)
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 7.0 KiB |
Loading…
Reference in New Issue