mirror of
https://github.com/APercy/automobiles_pck
synced 2025-08-21 20:35:48 +02:00
sound fix
This commit is contained in:
parent
268e3d8f70
commit
5e3f4c12d8
@ -288,6 +288,7 @@ minetest.register_entity("automobiles_buggy:buggy", {
|
|||||||
_light_old_pos = nil,
|
_light_old_pos = nil,
|
||||||
_last_ground_check = 0,
|
_last_ground_check = 0,
|
||||||
_last_light_move = 0,
|
_last_light_move = 0,
|
||||||
|
_last_engine_sound_update = 0,
|
||||||
|
|
||||||
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
||||||
return minetest.serialize({
|
return minetest.serialize({
|
||||||
@ -596,8 +597,12 @@ minetest.register_entity("automobiles_buggy:buggy", {
|
|||||||
if self.sound_handle then minetest.sound_stop(self.sound_handle) end
|
if self.sound_handle then minetest.sound_stop(self.sound_handle) end
|
||||||
--minetest.chat_send_player(self.driver_name, "Out of fuel")
|
--minetest.chat_send_player(self.driver_name, "Out of fuel")
|
||||||
else
|
else
|
||||||
|
self._last_engine_sound_update = self._last_engine_sound_update + dtime
|
||||||
|
if self._last_engine_sound_update > 0.300 then
|
||||||
|
self._last_engine_sound_update = 0
|
||||||
buggy.engine_set_sound_and_animation(self, longit_speed)
|
buggy.engine_set_sound_and_animation(self, longit_speed)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local energy_indicator_angle = automobiles_lib.get_gauge_angle(self._energy)
|
local energy_indicator_angle = automobiles_lib.get_gauge_angle(self._energy)
|
||||||
self.fuel_gauge:set_attach(self.object,'',BUGGY_GAUGE_FUEL_POSITION,{x=0,y=0,z=energy_indicator_angle})
|
self.fuel_gauge:set_attach(self.object,'',BUGGY_GAUGE_FUEL_POSITION,{x=0,y=0,z=energy_indicator_angle})
|
||||||
|
@ -57,10 +57,10 @@ end
|
|||||||
function buggy.engine_set_sound_and_animation(self, _longit_speed)
|
function buggy.engine_set_sound_and_animation(self, _longit_speed)
|
||||||
--minetest.chat_send_all('test1 ' .. dump(self._engine_running) )
|
--minetest.chat_send_all('test1 ' .. dump(self._engine_running) )
|
||||||
if self.sound_handle then
|
if self.sound_handle then
|
||||||
if (math.abs(self._longit_speed) > math.abs(_longit_speed) + 0.08) or (math.abs(self._longit_speed) + 0.08 < math.abs(_longit_speed)) then
|
--if (math.abs(self._longit_speed) > math.abs(_longit_speed) + 0.08) or (math.abs(self._longit_speed) + 0.08 < math.abs(_longit_speed)) then
|
||||||
--minetest.chat_send_all('test2')
|
--minetest.chat_send_all('test2')
|
||||||
buggy.engineSoundPlay(self)
|
buggy.engineSoundPlay(self)
|
||||||
end
|
--end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -270,6 +270,7 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
_light_old_pos = nil,
|
_light_old_pos = nil,
|
||||||
_last_ground_check = 0,
|
_last_ground_check = 0,
|
||||||
_last_light_move = 0,
|
_last_light_move = 0,
|
||||||
|
_last_engine_sound_update = 0,
|
||||||
|
|
||||||
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
||||||
return minetest.serialize({
|
return minetest.serialize({
|
||||||
@ -569,8 +570,12 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
if self.sound_handle then minetest.sound_stop(self.sound_handle) end
|
if self.sound_handle then minetest.sound_stop(self.sound_handle) end
|
||||||
--minetest.chat_send_player(self.driver_name, "Out of fuel")
|
--minetest.chat_send_player(self.driver_name, "Out of fuel")
|
||||||
else
|
else
|
||||||
|
self._last_engine_sound_update = self._last_engine_sound_update + dtime
|
||||||
|
if self._last_engine_sound_update > 0.300 then
|
||||||
|
self._last_engine_sound_update = 0
|
||||||
roadster.engine_set_sound_and_animation(self, longit_speed)
|
roadster.engine_set_sound_and_animation(self, longit_speed)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local energy_indicator_angle = automobiles_lib.get_gauge_angle(self._energy)
|
local energy_indicator_angle = automobiles_lib.get_gauge_angle(self._energy)
|
||||||
self.fuel_gauge:set_attach(self.object,'',ROADSTER_GAUGE_FUEL_POSITION,{x=0,y=0,z=energy_indicator_angle})
|
self.fuel_gauge:set_attach(self.object,'',ROADSTER_GAUGE_FUEL_POSITION,{x=0,y=0,z=energy_indicator_angle})
|
||||||
|
@ -55,10 +55,10 @@ end
|
|||||||
function roadster.engine_set_sound_and_animation(self, _longit_speed)
|
function roadster.engine_set_sound_and_animation(self, _longit_speed)
|
||||||
--minetest.chat_send_all('test1 ' .. dump(self._engine_running) )
|
--minetest.chat_send_all('test1 ' .. dump(self._engine_running) )
|
||||||
if self.sound_handle then
|
if self.sound_handle then
|
||||||
if (math.abs(self._longit_speed) > math.abs(_longit_speed) + 0.08) or (math.abs(self._longit_speed) + 0.08 < math.abs(_longit_speed)) then
|
--if (math.abs(self._longit_speed) > math.abs(_longit_speed) + 0.08) or (math.abs(self._longit_speed) + 0.08 < math.abs(_longit_speed)) then
|
||||||
--minetest.chat_send_all('test2')
|
--minetest.chat_send_all('test2')
|
||||||
roadster.engineSoundPlay(self)
|
roadster.engineSoundPlay(self)
|
||||||
end
|
--end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user