Don't use looped sounds on subway
(causes engine bugs with dangling sound handles)master
parent
1f26781b6a
commit
ae88f29481
|
@ -532,7 +532,7 @@ function wagon:on_step(dtime)
|
||||||
self:update_animation(gp.velocity, self.old_velocity)
|
self:update_animation(gp.velocity, self.old_velocity)
|
||||||
end
|
end
|
||||||
if self.custom_on_velocity_change then
|
if self.custom_on_velocity_change then
|
||||||
self:custom_on_velocity_change(gp.velocity, self.old_velocity or 0)
|
self:custom_on_velocity_change(gp.velocity, self.old_velocity or 0, dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ advtrains.register_wagon("subway_wagon", {
|
||||||
is_locomotive=true,
|
is_locomotive=true,
|
||||||
drops={"default:steelblock 4"},
|
drops={"default:steelblock 4"},
|
||||||
horn_sound = "advtrains_subway_horn",
|
horn_sound = "advtrains_subway_horn",
|
||||||
custom_on_velocity_change = function(self, velocity, old_velocity)
|
custom_on_velocity_change = function(self, velocity, old_velocity, dtime)
|
||||||
if not velocity or not old_velocity then return end
|
if not velocity or not old_velocity then return end
|
||||||
if old_velocity == 0 and velocity > 0 then
|
if old_velocity == 0 and velocity > 0 then
|
||||||
minetest.sound_play("advtrains_subway_depart", {object = self.object})
|
minetest.sound_play("advtrains_subway_depart", {object = self.object})
|
||||||
|
@ -87,13 +87,17 @@ advtrains.register_wagon("subway_wagon", {
|
||||||
minetest.sound_stop(self.sound_arrive_handle)
|
minetest.sound_stop(self.sound_arrive_handle)
|
||||||
self.sound_arrive_handle = nil
|
self.sound_arrive_handle = nil
|
||||||
end
|
end
|
||||||
if velocity > 0 and not self.sound_loop_handle then
|
if velocity > 0 and (self.sound_loop_tmr or 0)<=0 then
|
||||||
self.sound_loop_handle = minetest.sound_play({name="advtrains_subway_loop", gain=0.3}, {object = self.object, loop=true})
|
self.sound_loop_handle = minetest.sound_play({name="advtrains_subway_loop", gain=0.3}, {object = self.object})
|
||||||
|
self.sound_loop_tmr=3
|
||||||
|
elseif velocity>0 then
|
||||||
|
self.sound_loop_tmr = self.sound_loop_tmr - dtime
|
||||||
elseif velocity==0 then
|
elseif velocity==0 then
|
||||||
if self.sound_loop_handle then
|
if self.sound_loop_handle then
|
||||||
minetest.sound_stop(self.sound_loop_handle)
|
minetest.sound_stop(self.sound_loop_handle)
|
||||||
self.sound_loop_handle = nil
|
self.sound_loop_handle = nil
|
||||||
end
|
end
|
||||||
|
self.sound_loop_tmr=0
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
}, S("Subway Passenger Wagon"), "advtrains_subway_wagon_inv.png")
|
}, S("Subway Passenger Wagon"), "advtrains_subway_wagon_inv.png")
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue