added more gauges and improved die by destruction

This commit is contained in:
Alexsandro Percy 2023-06-28 19:48:53 -03:00
parent 57d038912e
commit f18cc7e441
5 changed files with 31 additions and 9 deletions

View File

@ -192,12 +192,17 @@ function airutils.logic(self)
--if is_flying then minetest.chat_send_all('is flying') end
local is_attached = airutils.checkAttach(self, player)
if self._indicated_speed == nil then self._indicated_speed = 0 end
if not is_attached then
-- for some engine error the player can be detached from the machine, so lets set him attached again
airutils.checkattachBug(self)
end
if self._custom_step_additional_function then
self._custom_step_additional_function(self)
end
if longit_speed == 0 and is_flying == false and is_attached == false and self._engine_running == false then
return
end
@ -450,10 +455,6 @@ function airutils.logic(self)
self.object:set_bone_position("aileron.l", self._aileron_l_pos, {x=self._rudder_angle - 90,y=0,z=0})
end
if self._custom_step_additional_function then
self._custom_step_additional_function(self)
end
-- calculate energy consumption --
airutils.consumptionCalc(self, accel)

View File

@ -104,10 +104,29 @@ function airutils.plot_speed_gauge(self, scale, place_x, place_y)
--local speed_angle = -(speed_percentage*350)/100
--minetest.chat_send_all(dump(fuel_angle))
local fuel = "^[resize:"..scale.."x"..scale.."^[combine:"..bg_width_height.."x"..bg_width_height..":"
local speed = "^[resize:"..scale.."x"..scale.."^[combine:"..bg_width_height.."x"..bg_width_height..":"
..place_x..","..place_y.."=airutils_speed_gauge.png:"
--fuel = fuel..get_pointer(speed_angle-180, gauge_center_x, gauge_center_y, 1)
return fuel
return speed
end
function airutils.plot_power_gauge(self, scale, place_x, place_y)
local bg_width_height = 100
local pointer_img = 8
local gauge_center = (bg_width_height / 2) - (pointer_img/2)
local gauge_center_x = place_x + gauge_center
local gauge_center_y = place_y + gauge_center
--local speed_percentage = (curr_level*100)/max_level
--local speed_angle = -(speed_percentage*350)/100
--minetest.chat_send_all(dump(fuel_angle))
local rpm = "^[resize:"..scale.."x"..scale.."^[combine:"..bg_width_height.."x"..bg_width_height..":"
..place_x..","..place_y.."=airutils_rpm_gauge.png:"
--fuel = fuel..get_pointer(speed_angle-180, gauge_center_x, gauge_center_y, 1)
return rpm
end

View File

@ -347,14 +347,16 @@ function airutils.testImpact(self, velocity, position)
local player_name = self.driver_name
--minetest.chat_send_all('damage: '.. damage .. ' - hp: ' .. self.hp_max)
if self.hp_max < 0 then --if acumulated damage is greater than 50, adieu
airutils.destroy(self, true)
if self.hp_max < 0 then --adieu
airutils.destroy(self, self._enable_explosion)
end
local player = minetest.get_player_by_name(player_name)
if player then
if player:get_hp() > 0 then
player:set_hp(player:get_hp()-(damage/2))
local hurt_by_impact_divisor = 0.5 --less is more
if self.hp_max > 0 then hurt_by_impact = 2 end
player:set_hp(player:get_hp()-(damage/hurt_by_impact_divisor))
end
end
if self._passenger ~= nil then

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB